Skip to main content
A newer version of this page is available. .

TcxCustomDataController.OnCompare Event

Occurs when sorting records within a grid control.

Declaration

property OnCompare: TcxDataControllerCompareEvent read; write;

Remarks

The OnCompare event occurs when values from two records are compared when sorting. The ARecordIndex1 and ARecordIndex2 parameters identify indexes of records that must be compared. The item for which the event is generated is specified by the AItemIndex parameter. When working in a Grid View, the ItemIndex parameter defines the TcxGridColumn object position within the collection of owner columns. When working in a Card View, the ItemIndex parameter defines the card row position of the TcxGridCardViewRow class.

Values are provided by V1 and V2 parameters. To set the result of the compare operation you need to assign a negative value to Compare if V1<V2, zero if V1=V2 and a positive value if V1>V2. You must always return the result of the compare operation.

The ADataController parameter specifies the data controller which fires the event.

Use the OnCompare event when you want to change the default comparison rules. For instance, you can group records with NULL values and place them at the bottom of all records, then group other rows according to their values (the same year, month) and so on.

Note

We recommend that you disable the use of multi-threaded algorithms for sorting records in the ExpressQuantumGrid View if your OnCompare event handler implementation is not thread-safe.

See Also