Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
Rebuild tree with same nodes expanded/collapsed
posted

Is there a recommended solution to recreate a tree node by node and have the same nodes expanded/collapsed?

 For example in the instance where you have a file explorer like app which has been generated programmatically based on an underlying customer data structure and would like to rebuild the tree but retain the expanded/collapsed nodes.  Almost as if you wanted to clone the tree and have it displayed exactly the same.

 I can imagine the brute force method of traversing the tree and keep a tally of all nodes that are expanded and reapply them.  This method doesn't really scale very well, but is that the only way?

  • 69832
    Offline posted

    You can use the SaveAsXml/SaveAsBinary methods to serialize an object graph of the control, and LoadFromXml/LoadFromBinary to deserialize.