Solved

Indentify TreeView Nodes

Posted on 2010-11-18
3
248 Views
Last Modified: 2012-05-10
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
Comment
Question by:crp81
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
s_chilkury earned 500 total points
ID: 34170720
TreeNode node = tv1.SelectedNode;

The above code will give you the selected node.
0
 

Expert Comment

by:rajeshrolen
ID: 34170770
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
 

Expert Comment

by:rajeshrolen
ID: 34170783
this is good link, this will provide you more help with example regarding treeview:

http://dotnetperls.com/treeview
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now