RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TTreeNodes.CustomSort Method

Sort tree nodes.

Pascal
function CustomSort(SortProc: TTVCompare; Data: Longint; ARecurse: Boolean = False): Boolean;
C++
__fastcall Boolean CustomSort(TTVCompare SortProc, Longint Data, Boolean ARecurse = False);

CustomSort triggers node sorting or resorting, using a comparison routine indicated by the SortProc parameter. The Data parameter is passed to the comparison routine. The optional ARecurse parameter (default false) specifies that sorting should recursively descend the node tree and sort each subtree in turn. 

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 compare of node captions. 

In the comparison routine, the lParam1 and lParam2 parameters refer to two nodes when cast to TTreeNode. The lParamSort parameter is the value previously passed to the Data parameter of CustomSort. The return value of the comparison routine indicates the relative sort order of IParam1 and IParam2:

Return Value 
Meaning 
< 0  
IParam1 comes before IParam2  
0  
IParam1 and IParam2 are equivalent  
> 0  
IParam2 comes before IParam1  

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!