


In many cases, it is impractical to fully load a Tree-View with all of the items it logically contains. For example, if you want to represent every file on a local disk drive in its directory hierarchy, a Tree-View is a natural way to do this. However, it could take a long time to populate this tree: every file on the entire drive would have to be located. One way to solve this problem is to populate only the top level of the tree at first, and then populate only those sub-levels that the user visits.
In order to do this, you have to tell the Tree-View whether an item is entitled to have children when you add the item to the control. If you did not do this, the control would not allow the user to expand that item. You establish the ability to add children to an item by setting the property HAS-CHILDREN to "1" when you add the parent item. For example:
MODIFY TV-1, ITEM-TO-ADD = "Parent Item" GIVING PARENT-1, HAS-CHILDREN = 1
This informs the control that the item has children, even though the children are not physically present in the control.
There are two approaches you can take when managing the children of a particular item. You can add them the first time the parent item expands, and then leave them in the control, or you can add them as the parent expands and delete them when the parent collapses.
More: