Treeview ?

Chris Ara
06-17-2006, 10:03 AM
Is there any way I can save a treeview object into a file, so when I load up the file I can use the saved object to populate a treeview. I have form with a tree view with several nodes and sub nodes and I can't figure out how to save a file where when I load it up it populates the treeview the way it was when you left off.

MikeJ
06-18-2006, 09:31 AM
There are several ways. You could always take that information and bind it to a dataset, thereby allowing you to save the information in something like an XML file - which you could then load the next time your program starts. You could also create a file structure of your own and parse it. Personally, the XML path is better because it would be done in the "recommended" Microsoft way.

Chris Ara
06-22-2006, 05:39 PM
I still do not see any functionality in the treeview object itself to save it's current state. I need something to save all the nodes and there subnodes in a ordered manner.

MikeJ
06-22-2006, 09:25 PM
This is where you create your own recursive procedure to do it for you. Here's the pseudo-code for what I'd do:

MyFunction(ByVal Node)
For Each node in TreeView
If node Has children
'Get the next level
MyFunction(ChildNode)
WriteToXML(ParentNodeName)
Else
'This is the bottom of the tree
MyFunction(NextNode)
WriteToXML(ChildNodeName)
End If
Next
End Function

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum