vcl-cxcustomdata-ea24e2cf.md
The procedural type for value comparison events in a data controller.
TcxDataControllerCompareEvent = procedure(ADataController: TcxCustomDataController; ARecordIndex1: Integer; ARecordIndex2: Integer; AItemIndex: Integer; const V1: Variant; const V2: Variant; var Compare: Integer) of object;
| Name | Type | Description |
|---|---|---|
| ADataController | TcxCustomDataController |
Provides access to the data controller that raised the current value comparison event.
| | ARecordIndex1 | Integer |
Returns the index of the record that contains the first compared value (V1).
The AItemIndex parameter returns the index of the current dataset field.
| | ARecordIndex2 | Integer |
Returns the index of the record that contains the second compared value (V2).
The AItemIndex parameter returns the index of the current dataset field.
| | AItemIndex | Integer |
Returns the index of the dataset field where the current comparison operation occurs.
ARecordIndex1 and ARecordIndex2 parameters return indexes of records where first (V1) and second (V2) compared values are stored.
| | V1 | Variant |
Returns the first compared value.
| | V2 | Variant |
Returns the second compared value.
| | Compare | Integer |
Specifies the comparison result (-1, 0, or 1).
Refer to the following section for details: Comparison Results.
|
Handle a value comparison event to implement a custom sorting algorithm in your application. Refer to the TcxCustomDataController.OnCompare event description for a code example.
Important
Disable multi-threaded calculations for data sort operations in a data controller if your value comparison event handler is not thread-safe.
Set the MultiThreadedOptions.Sorting property to bFalse to disable multi-threading for sort operations in the data controller.
The following table explains what Compare parameter values correspond to different results of the current value comparison operation:
| Compare Value | Description |
|---|---|
-1 or other negative value | V1 is treated as a smaller value than V2; therefore, V1 is positioned before V2. |
0 | V1 and V2 are considered equal. Both values retain their positions. |
1 or other positive value | V1 is treated as a larger value than V2; therefore, V1 is positioned after V2 |
The TcxCustomDataController.OnCompare event references the TcxDataControllerCompareEvent procedural type.
See Also