Robin V. Robin V. - 1 month ago 20
C# Question

Get treenode from contextmenu-item eventHandler

I've got a treeview with several treenodes. When I right-click a treenode i get a contextmenu
with different options, for example 'delete item'.

Is there a simple way to get the treenode object, that was right-clicked, in the eventHandler of the contextmenu-item ?

Answer

If you (right)click a node, doesn't it become the selected node?

TreeNode needed = TreeViewX.SelectedNode;

Cheers