I replaced:
panel.Controls.Clear();
with:
Clear(panel);
Where:
public static void Clear(C
You need remove controls you disposed, but there might be a better approach:
public static void Clear(Control ctrl) { foreach(Control c in ctrl.Controls) c.Dispose(); ctrl.Controls.Clear(); }