473,545 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to select treenode in treeview by name?

Wes
I have a treeview that I am continually added nodes to. Each time a new node
is added I would like to select that node.

Is this possible? I have looked at selectedNode, but I don't know how to
point that at a given node using the nodes name.

I have the nodes name and it's parents name. Does anyone know a good way to
find the node based on this information?

Thanks a bunch.
Nov 17 '05 #1
2 21734
I have a treeview that I am continually added nodes to. Each time a new node
is added I would like to select that node.
The easiest way to do that is probably

TreeNode node = // ... create node via Nodes.Add or whatever
yourTreeView.Se lectedNode = node;

Is this possible? I have looked at selectedNode, but I don't know how to
point that at a given node using the nodes name.

I have the nodes name and it's parents name. Does anyone know a good way to
find the node based on this information?


TreeNodes don't have names. I'm not sure if you mean the name of the
variable you use to reference the nodes or the Text property of the
node. Either way, it's probably easier to do as above.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2
Wes
Thanks for the response.

When I said name before I did mean the treeNode.text and treeNode.parent .text.

My question is how do I use the above mentioned information to get a new
treeNode object that I can select.

For Example

TreeNode myTreeNode = "how do I create treenode based on parent.text and
node.text?"
myTreeView.sele ctedNode = myTreeNode;
"Mattias Sjögren" wrote:
I have a treeview that I am continually added nodes to. Each time a new node
is added I would like to select that node.


The easiest way to do that is probably

TreeNode node = // ... create node via Nodes.Add or whatever
yourTreeView.Se lectedNode = node;

Is this possible? I have looked at selectedNode, but I don't know how to
point that at a given node using the nodes name.

I have the nodes name and it's parents name. Does anyone know a good way to
find the node based on this information?


TreeNodes don't have names. I'm not sure if you mean the name of the
variable you use to reference the nodes or the Text property of the
node. Either way, it's probably easier to do as above.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 17 '05 #3

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

Similar topics

4
20371
by: G Uljee | last post by:
How can I find and select an specific item in an treeview control? I want to create a search feature on my treeview. Thanks in advance, Gaby
5
10222
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 TreeNode(textvalueofname)) it always returns -1 and a TreeView.Nodes.Contains(etc.. always is false. I expect that it is only looking in the local Nodes...
3
1823
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 answer. I'd appreciate and help. Thanks. What I'm doing is creating a treeview with the structure as follows (this is the expanded view): -...
13
9043
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 path "Users\Administrators\John Doe"? Thank you in advance! Andre Nogueira
4
6914
by: praveen | last post by:
I have a form with treeview control loaded from xml document,text box, two buttons named "Find" and "FindNext" and my treeview which looks like below. Details |__ policy status |__ created by |__ cover type
3
4021
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 treeview and treenode class in asp.net is limited compared to vb.net's. In vb.net, the treenode had a nextnode property which was equivalent to...
5
2189
by: jotaefe | last post by:
Hi everyone, After visiting and using plenty of your solutions exposed in this great website, I've finally got across a problem that I can't find a solution anywhere. I have a TreeView that is populating a XML file that looks like this: <commandset> <commandgroup name="Initialization"> <command name="Reset" id="1"> ...
0
3284
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. Provide following view properties to listview, through View menu a. Tile b. Icon
4
3575
by: jmDesktop | last post by:
I have searched everywhere and tried several things. I have a treeview with and want to be able to only select a parent node. For example: root //don't want to drag this -parent1 //yes, drag this an only this because it is a parent --childOfParent1 //cannot drag this, only the parent --childOfParent1 //can only drag parent -parent2...
0
7415
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...
0
7675
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. ...
0
7928
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...
1
7440
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...
0
7775
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...
0
3470
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...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1030
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
726
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...

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.