TcxDataControllerCompareEvent Type
The procedural type for value comparison events in a data controller.
Declaration
TcxDataControllerCompareEvent = procedure(ADataController: TcxCustomDataController; ARecordIndex1: Integer; ARecordIndex2: Integer; AItemIndex: Integer; const V1: Variant; const V2: Variant; var Compare: Integer) of object;
Parameters
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 ( The |
ARecordIndex2 | Integer | Returns the index of the record that contains the second compared value ( The |
AItemIndex | Integer | Returns the index of the dataset field where the current comparison operation occurs.
|
V1 | Variant | Returns the first compared value. |
V2 | Variant | Returns the second compared value. |
Compare | Integer | Specifies the comparison result ( Refer to the following section for details: Comparison Results. |
Remarks
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.
Comparison Results
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 |
Direct TcxDataControllerCompareEvent Type Reference
The TcxCustomDataController.OnCompare event references the TcxDataControllerCompareEvent
procedural type.