TdxTreeViewNodeCompareEvent Type
The node comparison procedural type.
Declaration
TdxTreeViewNodeCompareEvent = procedure(Sender: TdxCustomTreeView; ANode1: TdxTreeViewNode; ANode2: TdxTreeViewNode; AData: TdxNativeInt; var ACompare: Integer) of object;
Parameters
Name | Type | Description |
---|---|---|
Sender | TdxCustomTreeView | The Tree View control that raised a node comparison event. |
ANode1 | TdxTreeViewNode | The first target tree node. |
ANode2 | TdxTreeViewNode | The second target tree node. |
AData | TdxNativeInt | Specifies a pointer to additional data for the custom comparison routine. |
ACompare | Integer | A result of the comparison. |
Remarks
The following table explains which ACompare parameter values correspond to specific comparison results:
Value | Description |
---|---|
A negative integer value | ANode1 is positioned above ANode2. |
0 | ANode1 is “equal” to ANode2. Both nodes retain their positions. |
A positive integer value | ANode1 is positioned below ANode2. |
The following OnCompare event handler sorts nodes by captions and places nodes with children at the top of the Tree View:
procedure TForm1.dxTreeViewControl1Compare(Sender: TdxCustomTreeView; ANode1,
ANode2: TdxTreeViewNode; AData: NativeInt; var ACompare: Integer);
begin
if ANode1.HasChildren = ANode2.HasChildren then
ACompare := CompareStr(ANode1.Caption, ANode2.Caption)
else
begin
if ANode1.HasChildren then
ACompare := -1
else
ACompare := 1;
end;
end;
The Tree View’s OnCompare event references the TdxTreeViewNodeCompareEvent type.