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

Add method in the treeview control

P: n/a
Does anyone have any real world experience using the .Net version of the
treeview control? If so, Can you recommend any good documentation sources
for learning more about it. i.e. Methods, etc.

I have a few different samples projects and am looking for many more to help
me understand everything I can about it.

One of my current issues is in trying to add a node. I use the ADD method
but under the .net version, you MUST add the node under the parent which
assumes you have a reference to the node collection:
(i.e tvParentNode.Add ("New child Node description")

If I don't have reference to the parent node, how do i get it?
tvOntheForm.Nodes() requires an integer. I know the value I put in the
description, but the index can change ?
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Ernest,

I have been using the WinForms TreeView in several real-world projects (see
the one in my signature, for example) and it works fine. I actually haven't
used anything except the MSDN library as the documentation.
One of my current issues is in trying to add a node. I use the ADD method
but under the .net version, you MUST add the node under the parent which
assumes you have a reference to the node collection:
(i.e tvParentNode.Add ("New child Node description")
This is simple. You first instantiate the parent (that is, root node):

Dim rootNode As TreeNode = New TreeNode(...) ' Specify node text etc. in the
arguments

Then, you add childs to that parent - you already know how this is done.

And finally, you attach the root to the tree itself:

treeView.Nodes.Add(rootNode)

P.S. The biggest difference between the .NET TreeView and the VB6 one is
probably that you are not stuck to the Add method to create new nodes - you
just can instantiate them directly.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Ernest Cook" <er*********@hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP11.phx.gbl... Does anyone have any real world experience using the .Net version of the
treeview control? If so, Can you recommend any good documentation sources
for learning more about it. i.e. Methods, etc.

I have a few different samples projects and am looking for many more to help me understand everything I can about it.

One of my current issues is in trying to add a node. I use the ADD method
but under the .net version, you MUST add the node under the parent which
assumes you have a reference to the node collection:
(i.e tvParentNode.Add ("New child Node description")

If I don't have reference to the parent node, how do i get it?
tvOntheForm.Nodes() requires an integer. I know the value I put in the
description, but the index can change ?


Nov 20 '05 #2

P: n/a
Cor
Hi Ernst,

The treeview is a nice thing to use.

What you have to remember is that it is not anymore a one part control, but
that there are two parts, the root and the node. (Treeview and treenodes)

What you are doing all the time is hanging (adding) nodes in a node and
those nodes again in the tree.

When you are used to, it is quiet easy. There is a lot of documentation
about it on MSDN.

The listview works in the same way; you can build your own explorer in no
time with those two. I hope this gives you some understanding about the
treeview.

I hope this helps a little bit
Cor
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.