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

selecting TreeView Node

P: n/a
Is it possible to select a TreeNode in a TreeView from code?

There isn't a property Focused nor a func Focus(). I tried with (all the
Nodes are collapsed in this moment):

TreeViewObject.SelectedNode = aSpecifiedTreeNode;

but it doesn't work. After this assignment SelectedNode remeins <undefined
value>.
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

You can use the mouse down event to find out which node has been clicked by
the user.

private void treeView1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
TreeNode selectedNode = null;
selectedNode = treeView1.GetNodeAt(e.X,e.Y);
}

The selectedNode will contain the Node that was clicked by the user.

--
Tarkeshwar
..Net Programmer
Fifth Generation Technologies

"UmmagummA" <fl***@mt.net.mk> wrote in message
news:uz**************@TK2MSFTNGP09.phx.gbl...
Is it possible to select a TreeNode in a TreeView from code?

There isn't a property Focused nor a func Focus(). I tried with (all the
Nodes are collapsed in this moment):

TreeViewObject.SelectedNode = aSpecifiedTreeNode;

but it doesn't work. After this assignment SelectedNode remeins <undefined
value>.

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.