2

I have TreeNode elements with this.ContextMenuStrip = contextMenuStrip1 and event, that auto-generated on double click in VS:

private void toolStripMenuItem1_Click(object sender, EventArgs e)
{

}

How can I get a TreeNode element, that I clicked on with right mouse button? As I see, EventArgs have nothing, to receive a "parent" element of TreeNode.

Thank you very much!

Arthur
  • 3,253
  • 7
  • 43
  • 75
  • I deleted my answer. See this answer, https://stackoverflow.com/questions/4886327/determine-what-control-the-contextmenustrip-was-used-on it is close to what I wrote, but the event is not attached to the TreeNode as I though, but to the ContextStrip. I believe it is a duplicated question – Gonzalo.- Jun 21 '17 at 19:37
  • No, that example for ContextMenuStrip doesn't work for me - I got a null for sourceControl on line `Control sourceControl = owner.SourceControl;` – Arthur Jun 21 '17 at 19:42
  • Try this instead https://stackoverflow.com/questions/14208944/c-sharp-right-click-on-treeview-nodes – Gonzalo.- Jun 21 '17 at 19:50
  • and one more chance https://stackoverflow.com/questions/2527/find-node-clicked-under-context-menu – Gonzalo.- Jun 21 '17 at 19:53

0 Answers0