RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TListControlItems.CompareItems Method

Returns the relative order of two items in the collection.

Pascal
function CompareItems(I1: TListControlItem; I2: TListControlItem): Integer; virtual;
C++
virtual __fastcall int CompareItems(TListControlItem I1, TListControlItem I2);

CompareItems is used internally to provide the default sort order for items in the list. It is used when the SortType property is not stNone. The Sort method also uses this as a comparison function. 

If I1 is greater than I2, CompareItems returns a value greater than 0. If I1 is the same as I2, CompareItems returns 0. If I1 is less than I2, CompareItems returns a value less than 0. 

CompareItems always uses an OnCompare event handler if it is assigned. Otherwise, it compares the captions of the items, taking into account the CaseSensitive property. Descendant classes can override CompareItems to provide a different default sort order. 

 

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