Vcl.ComCtrls.TTreeNode.CustomSort
Delphi
function CustomSort(SortProc: TTVCompare; Data: NativeInt; ARecurse: Boolean = False): Boolean;
C++
bool __fastcall CustomSort(PFNTVCOMPARE SortProc, NativeInt Data, bool ARecurse = false);
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | Vcl.ComCtrls.pas Vcl.ComCtrls.hpp |
Vcl.ComCtrls | TTreeNode |
Description
Triggers node sorting.
CustomSort triggers node sorting or resorting of the node's child nodes, using a comparison routine indicated by the SortProc
parameter.
The Data
parameter provides a way to pass information to a customized comparison routine. The CustomSort method and the default comparison routine do not use Data
.
The optional ARecurse
parameter (default False) specifies that sorting should recursively descend the node tree and sort each subtree in turn.
The Return Value of CustomSort indicates the success status of the sort.
If SortProc
is nil
(Delphi) or NULL
(C++), a default comparison routine is used. The default routine uses the OnCompare event handler for the associated TCustomTreeView object, if defined. If the OnCompare event handler is not defined, the default routine uses a simple case-sensitive comparison of node captions.
The comparison routine is defined like this:
Delphi type TTVCompare = function(lParam1, lParam2, lParamSort: Longint): Integer;
C++ typedef int (CALLBACK *PFNTVCOMPARE)(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
The lParam1
and lParam2
parameters refer to two nodes when cast to TTreeNode.
The lParamSort
parameter is the value previously passed in the Data
parameter of CustomSort.
The Return Value of the comparison routine indicates the relative sort order of lParam1
and lParam2
.
Return Value | Meaning |
---|---|
|
|
|
|
|
|
To sort the top-level nodes, use the CustomSort method of TTreeNodes.
Note: CustomSort does not work if the value of SortType is
stNone
.
See Also
Code Examples