Sorts rows in a DataWindow control, DataStore, or child DataWindow, or items in a TreeView or ListView control.
For syntax for DataWindows and DataStores, see the Sort method for DataWindows in the DataWindow Reference or the online Help.
To sort |
Use |
---|---|
Items in a TreeView |
|
Items in a ListView |
Sorts the children of an item in a TreeView control.
TreeView controls
treeviewname.Sort ( itemhandle , sorttype )
Argument |
Description |
---|---|
treeviewname |
The name of the TreeView control in which you want to sort items. |
itemhandle |
The item for which you want to sort its children. |
sorttype |
The sort method you want to use. Valid values are:
|
Integer. Returns 1 if it succeeds and -1 if it fails.
The Sort function only sorts the immediate level beneath the specified item. If you want to sort multiple levels, use SortAll. If you specify UserDefinedSort! as your sorttype, define your sort criteria in the Sort event of the TreeView control. To sort level 1 of a TreeView, set itemhandle to 0.
This example sorts the children of the current TreeView item:
long ll_tvi
ll_tvi = tv_foo.FindItem(CurrentTreeItem! , 0)
tv_foo.SetRedraw(false)
tv_foo.Sort(ll_tvi , Ascending!)
tv_foo.SetRedraw(true)
Sorts items in ListView controls.
ListView controls
listviewname.Sort ( sorttype, { column } )
Argument |
Description |
---|---|
listviewname |
The ListView in which you want to sort items. |
sorttype |
The method you want to use when you sort the ListView items. Values are:
|
column (optional) |
The number of the column by which you wish to sort the ListView items. |
Integer. Returns 1 if it succeeds and -1 if it fails.
The default sort is alphanumeric.
If you do not specify a column to sort, the first column is sorted.
This example sorts the items in column three of a ListView:
lv_list.SetRedraw(false)
lv_list.Sort(Ascending! , 3)
lv_list.SetRedraw(true)