4 个解决方案
#1
遍历panel的Controls 按着子控件的location的top值排序。
#2
排序进一个新的list<Control>不就好了
#3
List<Control> listStr = new List<Control>();
foreach (Control ctrl in this.flowLayoutPanel1.Controls)
{
listStr.Add(ctrl);
}
Control c = null;
for (int i = 0; i < listStr.Count; i++)
{
for (int j = i + 1; j < listStr.Count; j++)
{
if (listStr[j].Location.Y < listStr[i].Location.Y)
{
c = listStr[j];
listStr[j] = listStr[i];
listStr[i] = c;
}
}
}
foreach (Control ctrl in listStr)
{
MessageBox.Show(ctrl.Location.Y.ToString());
}
总算搞定了。。!
#4
谢谢给思路。!
#1
遍历panel的Controls 按着子控件的location的top值排序。
#2
排序进一个新的list<Control>不就好了
#3
List<Control> listStr = new List<Control>();
foreach (Control ctrl in this.flowLayoutPanel1.Controls)
{
listStr.Add(ctrl);
}
Control c = null;
for (int i = 0; i < listStr.Count; i++)
{
for (int j = i + 1; j < listStr.Count; j++)
{
if (listStr[j].Location.Y < listStr[i].Location.Y)
{
c = listStr[j];
listStr[j] = listStr[i];
listStr[i] = c;
}
}
}
foreach (Control ctrl in listStr)
{
MessageBox.Show(ctrl.Location.Y.ToString());
}
总算搞定了。。!
#4
谢谢给思路。!