Question

How can I restore state of nodes in VirtualStringTree (which ones were expanded) at tree rebuilding?

my application uses VirtualStringTree (one of the best components EVER!). Now, what I need is to rebuild the tree each time the application is started. In most cases however the "new" tree is the same as the one built last time... or at least very similar. What is the best way to restore the state of nodes? Which ones were expanded and so on ... I don't find it convinient to expand all the nodes manually each time I start the app... and so my users, I believe. Unfortunately, due to privacy restrictions I can't save the actual tree to a file and then load it, and compare the existing nodes when rebuilding (adding/removing when neccessary) ... I need some other way, please...

Was it helpful?

Solution

Store only topology of the tree, e.g. indexes of expanded nodes for each level.

Alternatively, you may form a list of hashes for some invariant nodes value and store hashes only for expanded nodes in that list. That way you will preserve state even if topology is changed, but at the cost of lowered privacy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top