• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Indentify TreeView Nodes

How con I identify the individual node selected (Clicked) in a TreeView.

I want to do the same as I do with labels:

 private void label_MouseLeave(object sender, EventArgs e)
            Label lbl = (Label)sender;   (How can I do this with nodes)

I am a beginner programmer so please detail code, Thanks
  • 2
1 Solution
TreeNode node = tv1.SelectedNode;

The above code will give you the selected node.
I think the mouseLeave event will not resolve your issue. i will suggest to use NodeMouseClick event so when you will click on any node this event will get fired and you can than take node using e.Node and do stuff with it what ever you wants.

 private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
            TreeNode tn = e.Node;

if this not get your desired result than plez provide me more detail that what exactly you wants to perform.

this is good link, this will provide you more help with example regarding treeview:

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now