hi everyone,
My code looks like this
dataentryTreeView.Dispose() ; // disposes off the old tree
InitializedataentryTreeView(); // again rebuilds the tree with the updated information
return true;Everytime i add,update or delete a node from my treeview it disposes the old tree view and rebuilds a new tree with updated information but the problem i am loosing the previous state of the tree view so it's becoming hard to navigate again and see where we have added the node.
could anyone help me in saving the state of the treeview before i dispose off the old treeview and restore the state back again after rebuilding the new treeview
thanks,
prawin josh

How to store a TreeView state and restore it back
camelo
Everytime i add a node to the tree, i add first that node information to the database table and then retrieve that data from table and rebuild the tree so for my logic it is mandatory to rebuild the tree as it's added to data table first and then to the tree.
thanks,help would be appreciated
regards
prawin josh
Ariston Darmayuda
Scottthedot
RK79
You can change the TreeNode.Text property instead of removing everything and rebuild it again. When you do this the expane state will be the same because you only change the Text property.
Barnhac
i am disposing off the tree and rebuilding it because my intention is to refresh the tree everytime i do some operation on it but for example if am adding a node to the treeview at level 1 and if i rebuild without diposing the old tree it is adding as a separate treenode so i am disposing off the old treeview and rebuilding a new one.
now before i dispose the old tree i want to save the exact expanded state of the tree view and restore the expanded state after rebuilding the tree so that it would exactly be in the previous expanded state showing where we added a node or so....
regards,
prawin josh
SHESHAGIRI
In my humble opinion this is a bad design and you should modify it! If you need any help with it, please let me know. I would rather help you with a new design then with help you in a evil direction.
nugget2
yes but i am building dyanamically from a datatable so eveytime i make some changes it has to reflect in my database and rebuild the tree from the database table so i am doing like that
changing the text property wont reflect in backend(database) anyway your solution works fine for edit but for add and delete nodes we have definitely reload the tree for that i want to save the previous expanded state and restore it back after rebuilding the tree
thanks,
prawin josh