Controlling which items are visible

There are two mechanisms in the tree control that allow you to programmatically control various aspects of which items are visible on the screen display. You can specify whether a given tree item is expanded or collapsed with the methods Col-lapse(item) and Expand(item). These methods change the display of the tree control, and have no effect if called on an item that does not have children. There is a convenience function, CollapseAndReset(item), that collapses the item and deletes all of its children from the tree. In addition, the method Toggle(item) changes the state of the item from expanded to collapsed or vice versa. You can query the current expanding state of the item with the method isExpanded(item).

Expanding or collapsing a tree item triggers two events in much the same way that changing the selection does. Before the expand or collapse, the event wx.EVT_TREE_ITEM_COLLAPSING or wx.EVT_TREE_ITEM_EXPANDING is triggered. In your handler method, you can block the expansion or collapse with the event Veto() method. After the expansion or collapse takes place, the event wx.EVT_ tree_item_collapsed or wx.EVT_TREE_!TEM_EXPANDED is triggered, depending, of course, on whether the event was an expansion or collapse of the item. All four of these events are types of the wx.TreeEvent class.

Was this article helpful?

0 0

Post a comment