I have a Button
in a FlowLayoutPanel
that I have a ContextMenuStrip
item attached to the MouseDown
event. The reason I have it on the mouse down event is that I have drag and drop functionality attached to the button and the flowlayout panel.
I need to beable to get to the button from the context menu when a user right clicks on the button.
I getting the right click and moving on from there then I am able to cast the down through the various level to the context menu item but I am unable to then go past the context menu item to the button that the context menu is being bound to on load of the button control.
I have checked the setting for the SourceControl
of the button and this is coming back as null.
How can I go about getting the button that the context menu is attached to?
ToolStripItem item = (sender as ToolStripItem);
ContextMenuStrip owner = item.Owner as ContextMenuStrip;
Button btn = owner.SourceControl as Button;