473,796 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Treenodes

Hi

As a VB6 user I'm unfamiliar with the Treeview control of VB2005. I read it
was changed but I have a hard time finding the right help/samples for my
problem.

In VB6 you had 1 collection, and adding a node was quite simple. Just
specify the nodes key and position relative to the key where you want to add
your new node.
In VB2005 you can't do that anymore. I looking for a sample or help how this
can be done now.
I've no problem adding the first level nodes, but more how directly add a
new node to an existing node referenced by the Key of that node.

I'll hope you understand my problem and can give me a help reference or
sample or even a solution

Thanks,
Bart
Dec 7 '07 #1
1 1906
Bart,

A treeview has many Nodes, and each Node has many Nodes within it.

TreeView1.Nodes .Add("Level1 Node")
TreeView1.Nodes ("Level1 Node").Nodes.Ad d("Level1 Child")

or more correctly

Dim myNode As Windows.Forms.T reeNode = TreeView1.Nodes .Add("Bob")
Dim myNodeChild As Windows.Forms.T reeNode = myNode.Nodes.Ad d("Bob's
Child")

in the 2nd example, when you add a tree node, it passes a reference of this
new node back, whcih you can store in a variable (myNode in this case).
You can then add nodes to myNode directly because you have a reference to
that node. When you do this, the Add again passes back a reference to the
new node (in this case myNodeChild, which is a 2nd level node in the tree
view).

Hope that helps.
Dan

"Bart Steur" <so*****@xs4all .nlwrote in message
news:ua******** ******@TK2MSFTN GP02.phx.gbl...
Hi

As a VB6 user I'm unfamiliar with the Treeview control of VB2005. I read
it was changed but I have a hard time finding the right help/samples for
my problem.

In VB6 you had 1 collection, and adding a node was quite simple. Just
specify the nodes key and position relative to the key where you want to
add your new node.
In VB2005 you can't do that anymore. I looking for a sample or help how
this can be done now.
I've no problem adding the first level nodes, but more how directly add a
new node to an existing node referenced by the Key of that node.

I'll hope you understand my problem and can give me a help reference or
sample or even a solution

Thanks,
Bart
Dec 7 '07 #2

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

Similar topics

1
10160
by: Dmitry Karneyev | last post by:
Hi! How to add tooltip to a TreeView node? Thanks for any advice! Dmitry.
9
5489
by: James Geurts | last post by:
Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. I'm only adding it to the tree node, where each custom tree node is then added to a normal tree control I'm trying to get an add-in to interact with the property window in VS.Net. Basically, I created a tool window containing a custom tree...
0
2420
by: Norbert Heidbüchel | last post by:
Hi all, I have read a lot of postings and web pages about drag and drop and treeviews, but could not find an answer to my problem. Sorry, if I missed something. I am trying to drag and drop treenodes defined by myself and don't understand, how to get the nodes data in the dragdrop event. I'm not very experienced in .NET and for sure there is a simple solution. I've written a short sample program, based on well known examples,
3
3166
by: MrNobody | last post by:
Ok, so I'm absoultely positive this was working last night, but today I'm getting this error in my program when I try to add a child node to a parent node of a tree... The error says: Message: The action being performed on this control is being called from the wrong thread. You must marshal to the correct thread using Control.Invoke or Control.BeginInvoke to perform this action. Stack Trace: at...
4
1367
by: | last post by:
I need to add a string property to a TreeNode object. One way I can do this is to use the tag property. Here is my question, can I do it this way, create a new class e.g. MyTreeNode which inherits from TreeNode and adds what I need. Will such an object be compatible with TreeView and TreeNodeCollection? thanks
10
1762
by: DrPete | last post by:
Hi People Could anyone suggest to me the best way to distinguish treenodes? By this I mean I'm in a situation where I have a TreeNode that displays a number of categories and within those nodes there are items of stock. There are a number of things I wish to do, such as use a ContextMenu to Rename the node, but I can't seemingly tell if the Node I'm renaming is a category or an item of stock.
0
1120
by: David | last post by:
Can WebControls be added to TreeNodes in the TreeView? David -- Be Positive Every Day
4
3602
by: Turban | last post by:
When I attempt to run the following code: protected void NavigationTreeView_TreeNodePopulate(object sender, TreeNodeEventArgs e) { TreeNode tn1 = new TreeNode("node1","node1"); TreeNode tn2 = new TreeNode("node2", "node2"); TreeNode newNode = new TreeNode("add me to both nodes", "add me to both nodes"); e.Node.ChildNodes.Add(tn1); e.Node.ChildNodes.Add(tn2);
2
2191
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
My first time using a TreeView: I've got a TreeView that I populated with some data and it has nodes. In the Properties window, I created an Event Handler for the TreeView's AfterSelect method, and it allows me to determine what Tree Node has been selected. However, if I expand the TreeView and select one of the Child TreeNodes, they do not trigger this event.
0
9679
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9527
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.