Hi lenusia,
You can retrieve the source by retrieving the ContextMenuStrip from the
ToolStripItem. You can retrieve the source control (the treeview you are
looking for) from the ContextMenuStrip.SourceControl. Like:
ToolStripMenuItem tsItem = (ToolStripMenuItem)sender;
ContextMenuStrip cMenuStrip = (ContextMenuStrip)tsItem.Owner;
Control theSourceControl = cMenuStrip.SourceControl;
TreeView myTreeView = (TreeView)theSourceControl;
MessageBox.Show(myTreeView.Name);
Note: you realy should check your objects before making explicit casts,
unless you are 100% shure nothing else could have raised the event.
Regards,
Nico
"Lenusia" wrote:
In my program I dynamically create treeViews and dynamically add nodes to them.
To each node I attach ContextMenuStrip which suppose allow delete selected
node
e.t.c.
How from inside click event handling function to find which node was selected?
sender is set to ToolStripItem clicked.