"poldoj" <po********@gmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I know that with this code I can add a level one node plus a level
two node:
Dim node As TreeNode
node = TreeView1.Nodes.Add("Level one node")
node.Nodes.Add("Level two node")
Well, at this point is possible to add a child node at that "level two
node" with code?
Just extend what you've got, remembering that whenever you
call Nodes.Add(), you get the a reference to the Node that after it
has been added, so
Dim level1 As TreeNode
Dim level2 As TreeNode
Dim level3 As TreeNode
level1 = TreeView1.Nodes.Add("Level one node")
level2 = level1.Nodes.Add( "Level two node" )
level3 = level2.Nodes.Add( "Level three node" )
That's fine, so long as you're only adding to the node you processed
last. If you need to find an arbitrary node that's already /in/ the
TreeView and add a new child node to /that/, it's just a little more
complicated, since the TreeView (unlike its VB "proper" predecessor)
doesn't expose any sort of "key" for each Node by which you could
access any Node directly.
HTH,
Phill W.