By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

How to select treenode in treeview by name?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.