PC Review


Reply
Thread Tools Rate Thread

Add method in the treeview control

 
 
Ernest Cook
Guest
Posts: n/a
 
      10th Oct 2003
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 ?


 
Reply With Quote
 
 
 
 
Dmitriy Lapshin [C# / .NET MVP]
Guest
Posts: n/a
 
      10th Oct 2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 ?
>
>


 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      10th Oct 2003
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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning TreeView Class Instance to a TreeView Control Loren Microsoft VB .NET 2 10th Apr 2008 04:40 PM
sort method in Treeview Red Baron Microsoft ASP .NET 1 22nd Jan 2008 03:58 PM
Treeview and Clone() method. Steven Microsoft C# .NET 2 3rd Jul 2006 09:15 PM
Why does the OnPaint method not be invoked in TreeView =?Utf-8?B?TmljaXlvdQ==?= Microsoft Dot NET Framework Forms 1 6th Apr 2005 05:15 PM
TreeView: Sorted Method dont work Michael Microsoft Access VBA Modules 2 14th Sep 2004 02:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:58 PM.