Type | Description | |||
SortOrderEnum | A SortOrderEnum expression that indicates the column's sort order. |
The control automatically sorts a column when the user clicks the column's header, if the SortOnClick property is exDefaultSort. If the SortOnClick property is exNoSort, the control disables sorting the items when the user clicks the column's header. There are two methods to get the items sorted like follows:
Using the SortOrder property of the Column object::
View1.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 sort descending the list of root items on the "Column 1"( if your control displays a list, all items are considered being root items
View1.Items.SortChildren 0, "Column 1", False
The SortType property of the Column object specifies the way how a column gets sorted. By default, a column gets sorted as string. If you need to sort your dates, the following snippet of code should be used:
With View1 With .Columns(0) .SortType = SortDate End With End With
If you need to sort a column using your special way you may want to use the SortType = SortUserData, or SortType = SortCellData that sorts the column using CellData / CellSortData property for each cell in the column. In this case, the CellData or CellSortData property holds numeric values only.