By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Treeview - relative position

P: n/a
forgive me, but I'm fairly new to VB.Net - having only used VB6 in the
past - -
I can easily place a node on the treeview (tv1.nodes.add(key, text)
BUT -
in VB6, we'd add a child node (TV1.NOdes.add...), and in that string, we'd
pick the parent/relative node, so that it would be placed under the correct
node....

How is that accomplished now?
Nov 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Elmo Watson wrote:
I can easily place a node on the treeview (tv1.nodes.add(key, text)
BUT -
in VB6, we'd add a child node (TV1.NOdes.add...), and in that string, we'd
pick the parent/relative node, so that it would be placed under the correct
node....

How is that accomplished now?
In much the same way.

Every TreeNode has a Nodes collection to which you can add [child]
TreeNodes. Annoyingly, in VB'2003, anyway, the Add method seems to
return an Index, not a TreeNode proper, so you have to muck about a
/bit/, as in

Dim oRootNode as TreeNode _
= tv1.Nodes.Add( "Root" )
Dim iIndex as Integer _
= oRootNode.Nodes.Add( "Child 1" )
Dim oChild1 as TreeNode _
= tv1.Nodes( iIndex )

iIndex = oChild1.Nodes.Add( "Grandchild 1" )
Dim oGrandChild As TreeNode _
= oChild1.Nodes( iIndex )

All of which is fine when initially loading the tree, but finding an
item that you've already loaded is a pain, since the TreeView doesn't
have keyed Nodes any more. But it's easy enough to implement your own.

HTH,
Phill W.
Nov 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.