Here's the code I have:
private void ClearSearchResults()
{
foreach (Control X in panel1.Controls)
{
panel1.Controls.Remove(X);
}
}
The problem is, when I run this method, only a single item is deleted, then if I click on a button again so the method can run again, another is deleted.
If I have 10 control in my panel, I'd have to click the "Delete" button on my program many times for all the control to be deleted.
What can I do in this case?