Compare Event (ModHFGrid)

See Also    Applies To

Occurs when the Sort property for the ModHFGrid is set to Custom Sort (9), so the user can customize the sort process.

Syntax

Private Sub object_Compare(row1, row2, cmp)

The Compare event syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
row1 A Long integer that specifies the first row in a pair of rows being compared.
row2 A Long integer that specifies the second row in a pair of rows being compared.
cmp An integer that represents the sort order of each pair, as described in Settings.

Settings

The event handler must compare row1 and row2 and set cmp to:

Setting Description
– 1 If row1 should appear before row2.
0 If both rows are equal or either row can appear before the other.
1 If row1 should appear after row2.

Remarks

When the Sort property is set to 9 (Custom Sort), the Compare event occurs once for each pair of rows in the ModHFGrid. As the Compare event uses row numbers instead of text values, you can compare any property value for that row, including RowData.

Note   While custom sorts are slower than built-in sorts, they provide the flexibility to sort a row by any column or using any cell property.