foreach (Control c in mForm.Controls)
{
}
存储的顺序是依据mForm上添加控件的顺序,
m1.Parent = myPanel;
m3.Parent = myPanel;
m4.Parent = myPanel;
m2.Parent = myPanel;
那么存储的顺序就是1 3 4 2
如果要存储界面上多个容器,可以进行递归
但是如果
m1.Parent = myPanel;
m3.Parent = myPanel;
m4.Parent = myPanel;
m2.Parent = myPanel;
m2.BringToFront();
由于m2调用函数bringtofront,顺序将变成1234。。。。。。真是郁闷
原文:http://www.cnblogs.com/littlemasterDa/p/6753953.html