Treeview Control bound to a sqladapter


Active member
Dec 29, 2005
Programming Experience
I have 2 tables in a SQL database, Categories and SubCategories. I want a treeview to be constructed from them basically Categories being the parent nodes and SubCategories being the child nodes. I want the user to add a new node, add a new child node to an existing parent node, also delete a child node or parent node and ofcourse edit the text of any parent node or child node.

Right now I have constructed the treeview by looping through the records returned by my query. I am facing a difficulty with saving. How would I know what changed in the treeview, which node got added, deleted or edited and how would I save the data back to the database?

If this treeview is linked to a datatable/dataset or sqladapter, the task would be VERY easy. Other than that I cannot think of any other solution than manually keeping track of what the user is doing. Please help !!!


VB.NET Forum Moderator
Staff member
Aug 17, 2004
Sydney, Australia
Programming Experience
Every TreeNode has a Tag property that can store anything. Assign the DataRow from which the node was created to the Tag. When you delete or edit a node you can Delete or edit the DataRow at the same time. When you create a new node you could either create a new DataRow then or wait until you're ready to save.
Top Bottom