[求助]遍历控件 居然逆序的问题
tabPage2中
一个按钮
30个PictureBox 名字依次为 p01 p02 p03 p04 ~~~ p30
如果文件夹中有20个图片,则依次在 PictureBox中显示
int iFileNum=20;//文件夹中图片的数量
int i = 0;
foreach (Control c in this.tabPage2.Controls)
{
if (c is PictureBox)
{
if(i+1>iFileNum)//如果i大于图片数,则取消赋值
{
return;
}
PictureBox temp = c as PictureBox;
temp.ImageLocation = testList[i];
i++;
}
}