I have single ContextMenuStrip
attached to more controls.
In use the Opening
event of ContextMenuStrip
to filter/disable some context entries.
In this case the property ContexteMenuStrip.SourceControl
is set correctly.
The problem I have is on the Click event of a ToolStripMenuItem
. This item is inside a ToolStripDropDown
.
I get the parent item with code:
Dim tsmi As ToolStripMenuItem = DirectCast(DirectCast(DirectCast(sender, ToolStripMenuItem).Owner, ToolStripDropDown).OwnerItem, ToolStripMenuItem)
then I get the ContextMenuStrip:
Dim contextMenu As ContextMenuStrip = DirectCast(tsmi.Owner, ContextMenuStrip)
but now, if I check contextMenu.SourceControl
is Nothing
.
Do you have any idea what is wrong or why SourceControl is not set in this case?
Thank you in advance