Occurs when the Sort property for the Grid control is set to Custom Sort (9) so the user can customize the sort process.
Private Sub object_Compare(row1, row2)
The Compare event syntax has these parts:
Part | Description |
---|---|
object | An object expression that evaluates to an object. |
row1 | A Long representing the first row in a pair of rows being compared. |
row2 | A Long representing the second row in a pair of rows being compared |
The event handler must compare rows row1 and row2.
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. |
When the Sort property is set to 9 (Custom Sort), the Compare event is triggered once for each pair of rows in the control that you want to compare. Because the Compare event uses row numbers instead of text values, you can use it to compare any property value for that row, including RowData. Custom sorts are always much slower that the built-in sorts. However, you can sort a row by any column or using any other cell property.