473,659 Members | 3,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble with Treeview vb.net 2005 express

2 New Member
Hi everyone,

I've gotten myself is bit of a mess where I'm loading a treeview. Basically I initialize the treeview control with a single root node we'll call it root. I do this by using the following syntax:
Expand|Select|Wrap|Line Numbers
  1. Dim tNode as TreeNode = New TreeNode("root")
  2. tNode.name = "root"
  3. TreeView1.Nodes.Add(tNode)
Now that I've gotten my root node set, I proceed to pass this node to another sub where some children are loaded to the node. The node is passed ByRef (as I think it should be since I'm changing the node a bit by adding children). I then call up the information for the children and proceed to add them to the root node that has been passed using much the same type of syntax as above. This is fine and this works.

The problem is that when the form is finally displayed I'm getting the root node added twice in the treeview control. Both have the children loaded. However, if I do a TreeView.Nodes. Count check it says there is only one node and not two.
It kind of looks like this:
Expand|Select|Wrap|Line Numbers
  1. root
  2.    |
  3.    |-Child 1
  4.    |-Child 2
  5.    |-Child 3
  6. root
  7.    |
  8.    |-Child 1
  9.    |-Child 2
  10.    |-Child 3
  11.  
Is this a bug in the TreeView control? I've double checked my code and I'm sure I'm only adding the root node once. Why is it being displayed twice with the exact same information?
Sep 19 '07 #1
1 1636
hariharanmca
1,977 Top Contributor
Hi everyone,

I've gotten myself is bit of a mess where .............
this by using the following syntax:
Expand|Select|Wrap|Line Numbers
  1. Dim tNode as TreeNode = New TreeNode("root")
  2. tNode.name = "root"
  3. TreeView1.Nodes.Add(tNode)
The node is passed ByRef (as I think it should be since I'm changing the node a bit by adding children).
I think you are adding root node two times 1 out side the method (As you mentioned above) and also inside the method. Just check once.
Sep 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
20062
by: Brian Smith | last post by:
Is there a way to avoid the default action of TreeNode expansion/contraction caused by double click? I can add an event handler to pop up my properties dialog on double click, but it has the unintended side-effect of toggling the expansion of that subtree. Thanks in advance, Brian
3
3232
by: Soul | last post by:
Hi, I am learning C# at the moment. I am trying to develop a simple program that will get data from a MS Access database into a dataSet. The result of dataSet should be something like: Year Semester Code Task --------------------------------------------------- "2003" "One" "CSE9020" "Deliverable Item 1" "2003" "One" "CSE9020" "Deliverable Item 2"
4
13304
by: BravesCharm | last post by:
I am trying to connect to SQL Server 2005 Express with Visual C# 2005 Express using this code: static void Main(string args) { SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\temp.MDF;User ID=MyUsername;password=MyPass;DATABASE=Test;Integrated Security=False;User Instance=True"); conn.Open();
14
15081
by: Mr.D | last post by:
How do I save/load the contents of a Treeview to a file? I have found several good examples written i VB6, but not a single one for VB.NET. Please help. ---- Tim
4
9396
by: Andrew Robinson | last post by:
I am using a TreeView to perform navigation and have a few nodes that need to generate a popup menu. For this, I use the SelectedNodeChanged event and then add the relevant "window.open" script to the page using the ClientScript.RegisterStartupScript method. This seems to work fine, but if the user clicks on the same node twice, the event doesn't fire a second time. I assume this is by design as the Node Selection hasn't changed, but...
3
4995
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : >************************************************************************ > <WebMethod(), System.Web.Services.Protocols.SoapRpcMethod()> _ > Public Function HelloWorld() As > <System.Xml.Serialization.SoapElementAttribute("return")> String
1
6616
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005 Express Edition x86: Component Microsoft SQL Server 2005 Express Edition x86 returned an unexpected value. ***EndOfSession***? Microsoft SQL Server 2005 Express Edition x86: Component Microsoft SQL Server 2005 Express Edition x86 returned an...
2
5504
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created programmatically. And I want to bind the selection of a TreeNode (which is a record) from the database) to a DetailsView which shows the datatable record for the selected TreeView node in the Details View. I am using IDE : Visual Web Developer 2005 Express; OS=...
2
2184
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
8428
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
8337
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
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8748
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8531
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5650
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
4175
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...
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.