I am working on an application where i am creating dynamic controls in a tablelayoutpanel, that includes two picture box and 3 combobox, each picturebox creates 2 GDI objects and each combobox creates 1, leading to the creation of 7 GDI objects in a row. But when my work is done I am trying to dispose the controls of tablelayoutpanel, but GDI objects are not getting disposed , leading to application crash. Everytime i open that tablelayoutpanel it appends the GDI objects to the previous count. After a point of time, it crosses 10,000 and application stops responding. I am trying something like this to dispose the GDI objects
for(int i =TableLayoutPanel.Controls.count -1;i >=0;--i )
{
TableLayoutPanel.Controls[i].Dispose();
}
this deletes some GDI objects but not most of them. can anybody help me out with this.Also when i close the form(not the entire application),still GDI objects are not getting disposed.