现状:
在winform下只允许10000个控件同时显示。
此方法不能释放资源,只是简单的删除index,而不是dispose()控件:
System.Windows.Forms.Control.ControlCollection.Clear();
下面的方法也不行,因为dispose()以后,index不变,而后面的数组全部前移,所以只能dispose一半:
foreach(Control ctl in this.Controls)
{
if(ctl != null)
ctl.dispose();
}
解决方法:
int CntControls = Controls.count;
for(int i=0; i<CntControls; i++){
if(Controls[0] != null)
Controls[0].Dispose();
}
}