Expand
Expand()
Force expansion of tree item
Applies to: TreeItem
Introduced in KCML version 5.02
Expand() Event
Occurs when an item is expanded for the first time
Applies to: Tree
Introduced in KCML version 5.02
Event
The Expand() event handler is called when the user attempts to expand a new tree branch. It will also be called when the Expand() method is called. It is only called once for each unique branch and therefore will not be called if the user later collapses and re-expands the branch. This makes this a suitable place to populate tree nodes on demand. If the branch is never expanded then the population will not take place.
The ExpandItem property is used to determine the unique index of the branch. This property can then be used with the Item() and Add() methods to add items to the branch before it is displayed, for example:
DEFEVENT Form1.tree1.Expand() LOCAL DIM a a = ..ExpandItem ..Item(a).Add("New node", 0) END EVENT
The ExpandChange() event is generated whenever a node is expanded or collapsed, except when an Expand() event is generated first.
Method
The Expand() method is used in conjunction with an object reference or the Item() method to expand levels within a tree control. If the level has never been expanded before then the Expand() event handler is called if it exists. The ExpandChange() event is called each time a level is expanded and again when a level is collapsed. For example:
.treeControl1.Item(ItemToExpand).Expand()
Tree levels can be collapsed again with the Collapse() method.