Compare Event

Fired when the Sort property is set to flexSortCustom, to allow custom comparison of rows.


Private Sub VSFlexGrid_Compare( ByVal Row1 As Long,  ByVal Row2 As Long, Cmp As Integer)


When the Sort property is set to flexSortCustom, this event is fired several times, to compare pairs of rows.

The event handler should compare rows Row1 and Row2 and return the result in the Cmp parameter. The result should be:





If Row1 should appear before Row2.


If the rows are equal (as far as sorting goes).


If Row1 should appear after Row2.


Note that custom sorts are orders of magnitude slower than the built-in sorts, so you should avoid using them unless your data sets are small. Usually, there are good alternatives to a custom sort:

If you are sorting dates, set the ColDataType property to flexDTDate and the generic sorting settings will sort the dates correctly.

If you are sorting international strings, the generic and string settings will sort the value correctly.

If you want to sort based on arbitrary criteria (for example, "Urgent", "High", "Medium", "Low"), use a hidden column with numerical values that correspond to the criteria you are using.

See Also

VSFlexGrid Control