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

TreeNode as ByRef

42
I was doing some treeNode related work and passed a treenode as a reference(though I could pass a copy of reference using ByVal). And the result was duplicated nodes in TreeView. This is not a problem but I just want to know why it duplicates Node, My code follows, just a treeview and a button is needed in a form. Thanks for help



Expand|Select|Wrap|Line Numbers
  1. Option Strict On
  2. Public Class Form1
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         CheckFromList(TreeView1.Nodes(0))
  5.     End Sub
  6.     Public Shared Sub CheckFromList(ByRef NodetoCheck As TreeNode)
  7.         For Each node2 As TreeNode In NodetoCheck.Nodes
  8.             If node2.Text = "David" Then
  9.                 node2.Checked = True
  10.             End If
  11.         Next
  12.     End Sub
  13.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  14.         TreeView1.CheckBoxes = True
  15.         Dim tn As TreeNode = TreeView1.Nodes.Add("<<Top>>")
  16.         tn.Nodes.Add("David")
  17.     End Sub
  18. End Class
Mar 7 '09 #1
3 2476
Frinavale
9,735 Expert Mod 8TB
How do you know that the node is duplicated?


-Frinny
Mar 9 '09 #2
aryanbs
42
Frinny!
First of all thanks for looking into the code, I have posted the sample code which gave me such result. Did you try that? I am using Visual Studio 2008 and working with .Net Framework 3.5

My above statement
" just a treeview and a button is needed in a form. Thanks for help"
Just create a new project and add a treeview and button with their default name and paste my code, If same thing happens whats happening with me, you will surely see what I mean.

Thanks Again

Edit: By the way above code is just a sample done in clean project, I got this thing in a big project but making it easier to answerers to get the insight of the problem quickly
Mar 11 '09 #3
aryanbs
42
So let go this thread to pass in peace?
Mar 23 '09 #4

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

Similar topics

2
by: Benny Raymond | last post by:
More problems with this... When I run this code, the main form returns an invalid cast exception as it's executing the line "TreeNode n = (TreeNode) this.Nodes;" Does anyone know what would...
0
by: naija naija | last post by:
Hi All, I'm using the TreView Web Control for my MENU. And the Menu is populated from an XML file below. I want a way in which i can manipulate the XML when i want to manage it without having to...
3
by: markaelkins | last post by:
Hi. I am trying to enter a variable in the treenodesrc of a treenode. I am basically trying to send an ID variable into sql to return different records. I've searched everywhere and cannot find the...
0
by: fred | last post by:
I am using the clipboard to copy and paste a TreeNode but the Tag property does not seem to be copied. I use the Tag property for an Object that contains data relating to the TreeNode. The Tag...
11
by: Mano | last post by:
When settiing a TreeNode to bold the text label of that node is clipped. As describedin in the Bug Rebort FDBK16963 I set the underliying TreeView Fond to be bold. Now I have the strange...
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...
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. ...
1
by: jmDesktop | last post by:
I am trying to add nodes with keys to my treeview. I can add general nodes without problem with: //create new node TreeNode newNode = new TreeNode(myIdNumber); //create children TreeNode...
1
by: AAaron123 | last post by:
If you see this posted twice - sorry. My news reader showed my first post as "No Longer Available" I have the following in a .css file. The treeNodes behave as if they were "a" elements. ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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...

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.