473,394 Members | 1,935 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,394 software developers and data experts.

Treeview add node problem

Hi all, I have a treenode control and I would like to add a node in a
certain level as child. For example 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? (whitout select it with the mouse, just with code )

Thanks
Nov 21 '05 #1
5 6649
In article <#m**************@tk2msftngp13.phx.gbl>, poldoj wrote:
Hi all, I have a treenode control and I would like to add a node in a
certain level as child. For example 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? (whitout select it with the mouse, just with code )


TreeView1.Nodes(0).Nodes.Add ("Another node")

Is that what your looking for? Or am I misunderstanding the question?

--
Tom Shelton [MVP]
Nov 21 '05 #2
First of all, thanks for your reply Tom Shelton [MVP], I tried that code
-----
TreeView1.Nodes(0).Nodes.Add ("Another node")
-----

It just act like node.Nodes.Add("Level two node")
and if put a 1 instead of 0 an "out of range exception is throwed".
I need to add a level 3 node at an preexistent level 2, sorry for my bad
englsh. Example
---------
level 1
level 2a
level 2b
level 2c
level 3
---------

Its possible to add that "level 3" with code? I know that if I select with
the mouse "level 2c" than is possible to use

Dim node01 As New TreeNode

node01 = TreeView1.SelectedNode

node01.Nodes.Add("node added")

--------------
Nov 21 '05 #3
In article <e6**************@TK2MSFTNGP15.phx.gbl>, poldoj wrote:
First of all, thanks for your reply Tom Shelton [MVP], I tried that code
-----
TreeView1.Nodes(0).Nodes.Add ("Another node")
-----

It just act like node.Nodes.Add("Level two node")
and if put a 1 instead of 0 an "out of range exception is throwed".
I need to add a level 3 node at an preexistent level 2, sorry for my bad
englsh. Example
---------
level 1
level 2a
level 2b
level 2c
level 3
---------

Its possible to add that "level 3" with code? I know that if I select with
the mouse "level 2c" than is possible to use

Dim node01 As New TreeNode

node01 = TreeView1.SelectedNode

node01.Nodes.Add("node added")

--------------


treeview1.Nodes (0).Nodes(2).Nodes.Add ("level 3")

--
Tom Shelton [MVP]
Nov 21 '05 #4
"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.
Nov 21 '05 #5
dear Phill. W, thanks for your reply. Indeed is exactly that I mean. I have
an "already-in-the-treeview" node, and then I would like to add a child at
that node. Not so easy task to accomplish after your words :(

<quote>it's just a little more
complicated, since the TreeView...</quote>
Thanks however

"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> ha scritto nel messaggio
news:de**********@yarrow.open.ac.uk... "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.

Nov 21 '05 #6

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

Similar topics

4
by: Jeroen Ceuppens | last post by:
Hi, I want to make something that adds a TreeNode to the end of TreeView, that TreeView Looks like + Level 1 + Level 2 + Level 3 - Level last
4
by: Ian Powell | last post by:
Hi I've got objects in an sorted ArrayList like: P:\ P:\\DOCS P:\\i386 P:\\i386\ASMS P:\\i386\ASMS\1000 P:\\i386\ASMS\1000\MSFT
7
by: vsiat | last post by:
I am trying to create a treeview out of a database table with the typical structure ID, NAME, PARENTID, TYPE, EXTRA_INFO, where is linked to the . What I want to achieve is create a tree made...
13
by: André Nogueira | last post by:
Hi there. I know you can view a node's fullpath property, but is it posible to select a node using its path? Like, tell the treeview that the node that should be selected is the node with the...
0
by: Treeview Trouble | last post by:
I have an application where there are two radio buttons each of which populates a treeview control with a directory structure. Each radio button corresponds to a different directory which may or...
3
by: Shawn | last post by:
Hi. I'm working with the TreeView control in my ASP.NET 1.1 application. I have a problem I haven't been able to figure out. When I click on a node (not expand), whether it's a parent node, a...
8
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the...
1
by: Nikron | last post by:
Hi, I'm having an issue with the ASP.NET 2.0 Treeview control and persisting its' state accross requests. My Control is embedded within a master page and is used for site navigation. My problem...
0
by: bsturg21 | last post by:
Hello, I have an app that has a custom treeview which inherits the base treeview class and I am having a problem with the way the treeview is being redrawn. Each node in the treeview represents a...
0
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. ...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.