I have created a ContextMenuStrip
(called MenuPanels) with the idea of creating a right-click menu.
I have a TableLayoutPanel
with a Matrix of Panels and I've added a Mouse_Click
event to every panel, and then placed
if(e.Button == MouseButtons.Right)
{
MenuPanels.Show(Cursor.Position);
}
as part of the event.
And in MenuPanels I've added a Delete option, the idea would be to change the backgroundImage of the panel.
I've read through a lot of other questions that focus on similar facts but haven't been able to get the Panel from with the ContextMenuStrip
has been called, as the SourceControl returns null..
I've tried the methods in here.
And also tried to get the SourceControl from the Opening event (has suggested here) but haven't been successful with that either..