473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

TreeNode Collection


Hello,
I am trying to create a TreeNodeCollection and to attach it to a tree
view. How exactly can I do it?
I am trying to do:
TreeNodeCollection tnc=new TreeNodeCollection(node);
but keep getting errors.
How can I do it?
Thank you!
*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
7 9660
Hi Juli,

The basic procedure of adding nodes to an existing collection is like this:

TreeNode newNode = new TreeNode(someName);
this.TreeViewControl.Nodes.Add(newNode);

Is this what you are trying to do? Also, please post the code so that we
have a better idea.

HTH,
Rakesh Rajan
"juli jul" wrote:

Hello,
I am trying to create a TreeNodeCollection and to attach it to a tree
view. How exactly can I do it?
I am trying to do:
TreeNodeCollection tnc=new TreeNodeCollection(node);
but keep getting errors.
How can I do it?
Thank you!
*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #2
The TreeNodeCollection class does not have a public constructor. It is
created by the TreeView class.

To create a new collection of TreeNodes for a TreeView, first create an
array of TreeNodes, next, call Nodes.Clear() on the TreeView, then use
Nodes.AddRange() to add your array of TreeNodes.

Dale Preston
MCAD, MCDBA, MCSE

"juli jul" <ju******@yahoo.com> wrote in message
news:uP*************@tk2msftngp13.phx.gbl...

Hello,
I am trying to create a TreeNodeCollection and to attach it to a tree
view. How exactly can I do it?
I am trying to do:
TreeNodeCollection tnc=new TreeNodeCollection(node);
but keep getting errors.
How can I do it?
Thank you!
*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #3
Hello,
I have a function that expects to get this argument:TreeNodeCollection
parentnode
I was trying to create it without the public constractor that is not
avalible but I didn't seccess in it:

TreeNode tn=new TreeNode("aaa");
al.Add(tn);
this.treeView1.Nodes.Clear();
this.treeView1.Nodes.AddRange(al);

I get compilation error.
How can I create an instance of a TreeNodeCollection?
Thanks you very much

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #4
Pass the Nodes property of your TreeView to your method:

myFunction(myTreeView.Nodes);

Or change your method to accept an array of TreeNodes.

Dale Preston
"juli jul" <ju******@yahoo.com> wrote in message
news:uv*************@TK2MSFTNGP15.phx.gbl...
Hello,
I have a function that expects to get this argument:TreeNodeCollection
parentnode
I was trying to create it without the public constractor that is not
avalible but I didn't seccess in it:

TreeNode tn=new TreeNode("aaa");
al.Add(tn);
this.treeView1.Nodes.Clear();
this.treeView1.Nodes.AddRange(al);

I get compilation error.
How can I create an instance of a TreeNodeCollection?
Thanks you very much

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #5

Thanks but I need to add xml elements to a tree view and this is done by
the function which gets the following arguments:
private void FillTree(XmlNode node, TreeNodeCollection parentnode)
But it's not working if I pass the collection in this way.Could you
tell me how to do it?
Thanks!
*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #6
Can you post the line of code where you are calling the FillTree method?

Dale

"juli jul" <ju******@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...

Thanks but I need to add xml elements to a tree view and this is done by
the function which gets the following arguments:
private void FillTree(XmlNode node, TreeNodeCollection parentnode)
But it's not working if I pass the collection in this way.Could you
tell me how to do it?
Thanks!
*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #7
Hello,here is the line :
this.FillTree(oXmlDoc.DocumentElement,this.treeVie w1.Nodes);
but what I need is from some node to other and not all the xml doc ,how
can I do that?
Thanks in advance!
*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: sgalmeida | last post by:
greetings how can i check if a treeview contains a treenode with a specified text? i'm trying with the Nodes.Contains() method but doesn't work. I'm reading data from a database, and the data is...
5
by: nevin | last post by:
Hi, If I have a TreeView with loads of Nodes and they all have children etc, how do I find the index of a given node when I only know the Text value? If I use TreeView.Nodes.IndexOf(new...
0
by: Patrick.O.Ige | last post by:
I have this code below. All its suppose to do is to EXPAND / COLLAPSE ALL of my treeview. But when i use ASP.NET WEbmatrix it all works fine .. But with VS.NET is says TreeNodeCollection not...
7
by: Bob Hollness | last post by:
Hi all. I know this is easy. What have I missed? I want to iterate through all child nodes from the top. Dim treeVal as TreeNode = Nothing For Each treeVal in MyTree.Nodes if...
8
by: | last post by:
I have the following class : Public Class MyTreeNode Inherits TreeNode Dim mystring As String End Class Now, when I try to do this : ''''''''''''nodes is a TreeNodeCollection, s is string
0
by: Sagaert Johan | last post by:
Hi How can i create a treeNode that contains also a Combobox. I Added a combobox to the treeview controls collection, but when i scroll the treeview, the combobox stays at its location. I...
3
by: tanya foster | last post by:
Hello, I am re-writing a visual basic .net application(visual studio 2003) in an asp.net application(visual studio 2005). The vb.net application relied on a treeview and hence, treenodes. The...
1
by: Lukas Kurka | last post by:
Hi, Is there a way how to add Controls into TreeNode? Thank You Lukas
3
by: Jeff | last post by:
Hey ..NET 2.0 I'm trying to search a TreeView control for a specific TreeNode The code below doesn't work because it only searches the the top level of the nodes. I would like to program it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.