Skip to main content

TcxCustomListView.SortType Property

Specifies the sort type, applied to the items within the list view.

Declaration

property SortType: TSortType read; write; default stNone;

Property Value

Type Default
TSortType stNone

Remarks

The SortType property specifies how the items are sorted inside the list view. The following options are supported:

Value

Meaning

stNone

Specifies that sorting is not applied to items of the list view. This means that the control will not automatically resort items until the SortType property is set to another value. However, items can still be sorted programmatically by calling the AlphaSort or CustomSort method.

Changing the SortType property to stNone when items are already sorted will not restore the original order of items

stText

Specifies that items of the list view are sorted by their captions in ascending order. Each time the caption of an item is changed, items are resorted. To toggle the sorting order, call the AlphaSort method.

You can implement custom sorting logic by handling the OnCompare event. In this case, the stText value merely implies that items need to be resorted each time a item caption changes. Thus you must use this value if the sorting logic uses captions of items only (the Caption property) to perform item comparison. The resulting sorting order depends on the OnCompare event handler implementation.

stData

Setting the SortType property doesn’t apply any predefined sorting order to items. This value merely implies that items resorting must be invoked each time the value of a item’s Data property is changed. The sorting logic must be implemented by handling the OnCompare event.

Set the SortType property to the stData value if you implement sorting that is based on the Data property value of items and doesn’t depend on their Caption property value. If the sorting algorithm uses both properties, set the SortType property to stBoth.

stBoth

This value implies that items sorting takes place each time the Caption or Data property of a item is changed. The sorting logic must be implemented in the OnCompare event handler. Use the stBoth value if your sorting algorithm uses both the Caption and Data properties of items to perform item comparing. If only the Caption or Data property is used, set the SortType property to stText or stData respectively.

You may need to use a sorting procedure that uses custom item settings (other than the Caption or Data property) to perform sorting. In this case, you must leave the SortType property set to stNone to disable automatic item resorting when changing the mentioned properties. When settings used in your sorting algorithm are changed or items are added to the list view, you must manually call the AlphaSort method.

See Also