I'm using a tree control to dynamically access one of several objects. I am able to save these objects to file and load them back in to my application which automatically adds an item to the tree that is referenced to that object. One of the properties of the object is an "Expanded?" flag that specifies whether the item should be expanded in the tree control.
When loading a large set of items and populating the tree control, it's best to use the "Add Multiple Items to End" method. If I add items one at a time, the populating of tree items is visibly slow, so adding multiple items at once is the right method to use. The input to this method is an array of tree item clusters. The cluster has the following properties:
Left Cell String
By passing all these properties to the "Add Multiple Items to End" method, I can load those items in to the tree along with their settings instantly. One item that is missing from this cluster is an "Expanded" flag. In order to then set the expanded property of the tree items, I have to loop through the items and invoke the "Open/Close" method one item at a time. This is a slow process and is visible to the user.