Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a child relative to previous added child in Treeview 1

Status
Not open for further replies.

EagleTempest

Technical User
Jun 15, 2004
125
CA
VB .NET 2005

Without selecting the previously creating node, is it possible to add a child to previously created node?

For example:
Code:
With TreeView1
  .BeginUpdate()
  .Nodes.Add("Parent")
  .Nodes(0).Nodes.Add("Child1")
  .Nodes(0).Nodes.Add("Child2")
  .Nodes(0).Nodes(1).Nodes.Add("GrandChild")
  .EndUpdate()
End With

The code: .Nodes(0).Nodes(1).Nodes.Add("GrandChild") is a pain to use. Is there a way I can add a child node under Child2? What if the grandchild has grandchildren!! What a pain that would be to code.
 
Nodes.add always adds a root item not a child. Unless I'm doing something wrong.

This is with .NET 2.0.

 
dim n as node
n =treeview1.nodes.add("x")
n = n.nodes.add("y")
n.nodes.add("z")


Not tested as I don't have VS on this machine.


Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top