Sorting individual items or the entire tree.
Sorting tree items in the SRP Tree Control is straight forward as long as you keep a few things in mind. First, there are two ways to sort: persistent and instant. Second, sorting is based on an item's type. Third, setting an item's sort setting affects its immediate children only.
Persistent vs. Instant
Persistent sorting is done through any one of the sort properties: RootSort, ItemSort, or DefSort. Use these properties when you want items to always be sorted automatically when items are added or removed. Instant sorting is a one-time sort performed via the Sort method. Use this when you want ot manually sort at specific times.
Item Type
Sorting numbers is different than sorting strings. The ItemType property helps clue the SRP Tree Control into how an item compares to another item. If you plan to place numbers or dates into your tree, then make sure to use the "Number" or "Data" data type. Not all tree items have to have the same time, though it's wise to make all items you intend to sort the same type. If you plan to make all items the same type, you can optionally use the DefType property for convenience.
Sorting Children
It's important to keep in mind that setting an item's sort attribute affects only its immediate children. For this reason, there are several sort properties. The RootSort property sorts all the items at the root level, i.e., the children of the implicit Root Item. The ItemSort property sorts a specific item's children. Use "ItemSort[All]" to sort all existing items. The DefSort property establishes the sort setting of new items added to the tree. For example, to initialize a tree in which all items are always sorted, use the following two lines of code:
// Sort the entire tree Set_Property(@Window:".OLE_TREE", "OLE.RootSort", "A") Set_Property(@Window:".OLE_TREE", "OLE.DefSort", "A")