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

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 21709
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.SelectedNode = 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.selectedNode = 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.SelectedNode = 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
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
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...
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...
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...
4
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...
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...
5
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...
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. ...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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...

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.