The position of tree widget nodes within a tree can be controlled in several ways. When a tree node is created without the TOP or INDEX keywords, the default behavior is to position the new node last among its siblings. If the TOP keyword is specified, the new node is created as the first child. If the INDEX keyword is specified, the new node is created at the position specified.
Existing tree widget nodes can be repositioned using the SET_TREE_INDEX keyword to WIDGET_CONTROL. Use this keyword for reordering nodes within a an existing tree.
Note: The root node cannot be reordered relative to its siblings.
When positioning tree nodes using the INDEX or SET_TREE_INDEX keywords, the value is the desired zero-based index of the node. Values that are less than zero, or greater than or equal to the number of children will position the node as the last child.
You can use the TREE_INDEX keyword to WIDGET_INFOto discover the current position of a node. To get the node to a particular position, there are two additional useful keywords to WIDGET_INFO: the N_CHILDREN and ALL_CHILDREN keywords return the number and identifiers of a parent’s children. For example, a tree widget can be “walked” as follows:
children=WIDGET_INFO( node, /ALL_CHILDREN )
FOR i=0, WIDGET_INFO( node, /N_CHILDREN ) - 1 DO BEGIN