taz8020
asked on
Add node under a spacific node, VB.net treeview
Hi I want to be able to add a node, under a spacific node. may be by path or index?
I have a table in a typed dataset in a win app, and need to loop through each row. I have an ID field and a ParentID field. I want it to be able to have infanate child nodes. So the only way I can see of doing this is when adding a node look to see if there are child nodes then add them. |Just not sure how to go about doing this.
This is what I have so far:
For i = 0 To Me.DataSet.sections.Rows.C ount - 1
If Me.ActinicDataSet.Catalog_ section.Ro ws(i).Item ("ParentID ") = 0 Then
Me.TreeView1.Nodes.Add(Me. DataSet.se ctions.Row s(i).Item( "SectionTe xt"))
'Need to add child nodes here.
End If
Next
I have a table in a typed dataset in a win app, and need to loop through each row. I have an ID field and a ParentID field. I want it to be able to have infanate child nodes. So the only way I can see of doing this is when adding a node look to see if there are child nodes then add them. |Just not sure how to go about doing this.
This is what I have so far:
For i = 0 To Me.DataSet.sections.Rows.C
If Me.ActinicDataSet.Catalog_
Me.TreeView1.Nodes.Add(Me.
'Need to add child nodes here.
End If
Next
ASKER
Hi djjaries, thanks for that. Is there a way if datasouce has children add child node. and if that childnode has children add thoses nodes and so on.
I have an ID field and a ParentID field in the same data table.
eg
-id
--id
----id
-----id
-id
-----id
I have an ID field and a ParentID field in the same data table.
eg
-id
--id
----id
-----id
-id
-----id
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim childNode As TreeNode = New TreeNode("Text for new childnode")
TreeNode node = Me.TreeView1.Nodes.Add(Me.
node.Add( childNode )