I have a tree which I need to reload periodically to get updated data and new/deleted/moved nodes.
However each time I show the tree the nodes are collapsed, and it would be nicer for the user to see the tree expanded as it was before (with incorporating any changes with new/deleted/moved nodes). This is pretty much like the Windows Explorer tree, when another process adds a folder and the tree updates while maintaining the tree node states.
Any tips on how to implement this would be appreciated, other than maintaining all the states myself on expansion state events.
Boz
Hi,
Well, I guess we have to go back to Mike's advise.
"The best way to handle this is to avoid completely re-setting the tree's DataSource. If you set the DataSource property on the tree or you do something to the DataSource that causes it to send a Reset notification, then the tree has no choice but to throw away all of it's existing nodes and build a set of new ones based on the new data source.
If that's not possible, then the only alternative would be to store all of the expanded states yourself based on some primary key data on each node."
Marianne
Well, a way of achieving what I need without having to store all the state information myself?
I see Mike has already answered your question. I’m checking to see if there was anything further that I could help you with.
Hi Boz,
The best way to handle this is to avoid completely re-setting the tree's DataSource. If you set the DataSource property on the tree or you do something to the DataSource that causes it to send a Reset notification, then the tree has no choice but to throw away all of it's existing nodes and build a set of new ones based on the new data source.
If that's not possible, then the only alternative would be to store all of the expanded states yourself based on some primary key data on each node.