Solved

Indentify TreeView Nodes

Posted on 2010-11-18
3
247 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

14 Experts available now in Live!

Get 1:1 Help Now