Save treeview data to a database...

lidds

Well-known member
Joined
Oct 19, 2004
Messages
122
Programming Experience
Beginner
I have been searching the internet for what seems hours and cannot seem to find anything to help, so here I am.

What I have is a treeview control and I want to be able to add new parent and child nodes, not a problem. However I want to be able to also save the new nodes created to a database, so that when the form is reopened the treeview is populated from the database. Could someone please help me on how to do this as I'm sure someone must have done something simular in the past??

Thanks in advance

Simon
 
You can create a dataset with a schema such as:

ID
ParentID
Item

Then use a recursion system to populate a tree from a single table. If the ParentID is 0 it's a root node, otherwise it would be a child node of the ID value. You can then save the dataset/datatable as you wish.
 
Back
Top