I'm writing a program in c#, in which I create a flowlayoutpanel that contains a lot of panels. I have a button, and when the user clicks on it, I want to dispose the panels that I've created.
This is the code:
Expand|Select|Wrap|Line Numbers
- foreach (Control c in myFlowLayoutPanel.Controls)
- {
- ((Panel)c).Dispose();
- }
I've also tried to call to the garbage collector
Expand|Select|Wrap|Line Numbers
- GC.Collect();
Does anybody know how can I achieve this?
Thanks