我想遍历页面中的picturebox 获得picturebox .x的最大值和最小值,
foreach (Control c in this.Controls)
{
if (c.GetType() == typeof(PictureBox))
{
....................................//代码
}
}
求代码部分,谢谢!
foreach (Control c in this.Controls)
{
if (c.GetType() == typeof(PictureBox))
{
....................................//代码
}
}
求代码部分,谢谢!
foreach (Control c in this.Controls)
{
if (c.GetType() == typeof(PictureBox))
{
if (MinVal > c.Location.X)
{
MinVal = c.Location.X;
}
if (MaxVal < c.Location.X)
{
MaxVal = c.Location.X;
}
}
}
MessageBox.Show(MinVal + " " + MaxVal);
int max=0;
foreach (Control c in this.Controls)
{
if (c.GetType() == typeof(PictureBox))
{
if (MinVal > c.Location.X)
{
MinVal = c.Location.X;
continue;
}
if (MaxVal < c.Location.X)
{
MaxVal = c.Location.X;
continue;
}
}
}
MessageBox.Show(MinVal + " " + MaxVal);