Retrieves or sets a value that indicates whether the control sorts automatically the
data when the user click on column's caption.
Type | Description | |||
SortOnClickEnum | A SortOnClick expression that indicates whether the control sorts automatically the data when the user click on the column's header. |
Use the SortOnClick property to disable sorting items when the user clicks on the column's header. Use the SortBarVisible property to show the control's sort bar. Use the SingleSort property to allow sorting by single or multiple columns. Use the AllowSort property to avoid sorting a column when user clicks the column. Use the DefaultSortOrder property to specify the column's default sort order, when the user first clicks the column's header.
There are two methods to get the items sorted like follows:
Using the SortOrder property of the Column object::
Tree1.Columns(ColIndex).SortOrder = SortAscending
The SortOrder property adds the sorting icon to the column's header, if the DisplaySortIcon property is True.
Using the SortChildren method of the Items collection. The SortChildren sorts the items. The SortChildren method sorts the child items of the given parent item in the control. SortChildren will not recourse through the tree, only the immediate children of the item will be sorted. The following sample sorts descending the list of root items on the "Column 1"( if your control displays a list, all items are considered being root items ).
Tree1.Items.SortChildren 0, "Column 1", False
The control fires the Sort event when the control sorts a column ( the user clicks the column's head ) or when the sorting position is changed in the control's sort bar. Use the Sort event to sort the data when the SortOnClk property is exUserSort.