From RAD Studio API Documentation
Jump to: navigation, search


function CustomSort(SortProc: TLVCompare; lParam: LPARAM): Boolean;


bool __fastcall CustomSort(PFNLVCOMPARE SortProc, NativeInt lParam);


Type Visibility Source Unit Parent
function public
Vcl.ComCtrls TCustomListView


Sorts the items in the list using the specified ordering function.

Call CustomSort to sort the items in the list using the ordering function defined by the SortProc parameter:

 TLVCompare = function(lParam1, lParam2, lParamSort: Integer): Integer stdcall;

The SortProc parameter specifies an ordering function that compares the list items passed as lParam1 and lParam2. The ordering function returns an integer that indicates whether lParam1 is the same as lParam2 (return value is 0), lParam1 is greater than lParam2 (return value is greater than 0), or lParam1 is less than lParam2 (return value is less than 0). The lParam parameter of CustomSort is an optional value that is passed as the third parameter to the ordering function.

If the SortProc parameter is nil (Delphi) or NULL (C++), CustomSort compares the list items by generating an OnCompare event. This allows the OnCompare event handler to provide different ordering criteria (such as ascending vs. descending order), based on the value of the lParam parameter.

If the ordering function is not provided and there is no OnCompare event handler, CustomSort sorts items alphabetically by their Caption values.

CustomSort returns true if the list is successfully sorted.

Warning: CustomSort does not work if the application is running in virtual mode.

See Also

Code Examples