• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • 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
0
crp81
Asked:
crp81
  • 2
1 Solution
 
s_chilkuryCommented:
TreeNode node = tv1.SelectedNode;

The above code will give you the selected node.
0
 
rajeshrolenCommented:
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;
            MessageBox.Show(tn.Name);
        }

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

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

http://dotnetperls.com/treeview
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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