I'm trying to access the TAG of the parent control (a dynamic button) of the context menu strip sub item.
In my scenario, No. of buttons added dynamically on a form and a ContextMenuStrip named CMS
is attached with each dynamic button added.
BTN.ContextMenuStrip = CMS
here is my context menu strip design
Tag of the parent button should be return by clicking All
. But I'm always getting NULL.
Here is my code.
Dim child As ToolStripMenuItem = sender 'Sub item (text=All)
Dim parent As ToolStripItem = child.OwnerItem 'Parent Item (text=Check)
Dim CMStrip As ContextMenuStrip = parent.Owner 'Context menu strip
MsgBox(CMS.SourceControl.Text) 'Source control should be button but it's null.
I'm using .NET Framework 2.0.