Thank you, Hans for your proposal - yes, it turns out I missed the control.
Here is what I ended up doing:
panel.Visible = false;
while (panel.Controls.Count > 0)
{
panel.Controls[0].Dispose();
}
panel.Visible = true;
Basically, I hide the entire panel (which has no borders) before I remove each control. Recycling each control automatically removes the specified control from the parent container, which is nice. Finally, I make the container visible again.
source
share