Dividing your problems into 2 parts
- Getting Click event of PictureBox
- Removing some control on that click event
1. Getting Click event of PictureBox
In order to do that you simply have to Double-click the PictureBox and a method will be generated
Or you can attach new method with click event Like
picOneFaceUpA.MouseClick += new MouseEventHandler(your_event_handler);
Or:
picOneFaceUpA.MouseClick += new MouseEventHandler((o, a) => code here);
Ref:- Adding a mouse click eventhandler to a PictureBox
2. Removing some control on that click event
You have multiple options to remove control from the panel
foreach (Control item in panel1.Controls.OfType<ComboBox>())
{
panel1.Controls.Remove(item);
}
//to remove control by Name
foreach (Control item in panel1.Controls.OfType<Control>())
{
if (item.Name == "bloodyControl")
panel1.Controls.Remove(item);
}
//to remove just one control, no Linq
foreach (Control item in panel1.Controls)
{
if (item.Name == "bloodyControl")
{
panel1.Controls.Remove(item);
break; //important step
}
}
Ref:- Removing dynamic controls from panel
Hope this helps.!
Happy Coding.!!!