You must write a script to add items to a TreeView. You cannot add items in the painter as with other list controls. Although you can populate all the levels of the TreeView at once, TreeView events allow you to populate only branches the user looks at, which saves unnecessary processing.
Typically, you populate the first level of the TreeView when the control is displayed. This code might be in a window’s Open event, a user event triggered from the Open event, or the TreeView’s Constructor event. Then a script for the control’s ItemPopulate event would insert an item’s children when the user chooses to expand it.
The ItemPopulate event is triggered when the user clicks on an item’s plus button or double-clicks the item, but only if the item’s Children property is TRUE. Therefore, when you insert an item that will have children, you must set its Children property to TRUE so that it can be populated with child items when the user expands it.
You are not restricted to adding items in the ItemPopulate event. For example, you might let the user insert items by dragging from a ListBox or filling in a text box.