Compare

This event defines a custom sort order for rows in a Grid control.

Syntax

Private Sub grid_Compare(row1, row2, cmp)

Parameters

grid
Object expression that evaluates to a Grid control.
row1
First row in a pair of rows being compared.
row2
Second row in a pair of rows being compared.
cmp
Value that determines the order of the rows.

Remarks

When you set the Sort property to flexSortCustom, the Compare event occurs once for each pair of rows in the control that you want to compare. You should compare the rows manually and set a value for the cmp parameter.

The following table shows the values for cmp.

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