Showing results for 
Search instead for 
Did you mean: 

Tree control open/close items question

Go to solution

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
  • Child Text
  • Child Tag
  • Item Indent
  • Child Only?
  • Glyph Index

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.


Is there a faster way?


0 Kudos
Message 1 of 2
Accepted by topic author Synaesthete

Adding one element at time or looping throught all the elements of the tree is (a lot) faster if you defer the panel update before doing it and the restore it after.


Look here, for example:




Message 2 of 2