Right click tree node

K

Kevin Spencer

Use the HitTest method to get the node that was clicked.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.
 
A

Alan T

What I want to do is:
1) Attach a contextstrip menu to treeview
2) Right click a node and pop up the menu
3) If the node has specific text or tag value, then enable or disable some
menu items.
 
K

Kevin Spencer

Yes, of course. You call the HitTest method of the TreeView.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.
 
K

Kevin Spencer

This isn't rocket science. You want to know which node was clicked. So, you
want to handle the Click event of the TreeView Control. The only time you
can handle this event is when the mouse is clicked. The MouseEventArgs
passed to the event will tell you the coordinates of the mouse. You then use
those coordinates with the HitTest or the GetNodeAt method, passing those
coordinates to the method, to obtain a reference to the node that was
clicked.

See:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.treeview.aspx

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Sequence, Selection, Iteration.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top