最大值和最小值

net0003 2008-04-24 11:08:06
我想遍历页面中的picturebox 获得picturebox .x的最大值和最小值,
foreach (Control c in this.Controls)
{
if (c.GetType() == typeof(PictureBox))
{
....................................//代码
}
}
求代码部分,谢谢!
...全文
88 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
virusswb 2008-04-24
  • 打赏
  • 举报
回复
int min=0;
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);
晓轩 2008-04-24
  • 打赏
  • 举报
回复
Single MinVal=800,MaxVal=0;
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);
lake_cx 2008-04-24
  • 打赏
  • 举报
回复
重复了,接分
Nadia_sobw 2008-04-24
  • 打赏
  • 举报
回复
看下你以前的帖子
Nadia_sobw 2008-04-24
  • 打赏
  • 举报
回复
你这程序有问题啊

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧