求一个思路
页面
picturebox1 picturebox2 picturebox3
-----------------picturebox4--------------
picturebox4的长度是与上面三个picturebox的长度对应的,上面有几个picturebox还不确定,
如果只显示picturebox2和picturebox3,那么picturebox4怎么截取对应的长度
如下
picturebox2 picturebox3
---------picturebox4-------
应该怎么实现picturebox4左边的截取(右端截取我能实现,比如只出现picturebox1的情况),我想遍历出所有picturebox的location.x,但是遍历出来最小的是picturebox4的,我怎么才能得到picturebox2的location.x呢(我说的情况是假如,起始picturebox2出现不出现不一定)就是说我左端截取不会实现,请指教
[解决办法]
简单啊 就是说上面 123 是可有可无 可能都出现可能都不出现 而4的位置永远是 上面显示的图片最左一个的location.x
宽度永远是上面最左边一个图的location.x家最右一个图的location.x+最右一个图的width如果是这个意思我写个代码给你看
[解决办法]
- C# code
if (picturebox1.Visible = true)
{
if (picturebox2.Visible = false)
{
}
else if (picturebox3.Visible = false)
{
picturebox4.Width = (this.Width - picturebox1.Location.x) - (this.Width - picturebox2.Location.X - picturebox1.Width);
picturebox4.Location = new Point(picturebox1.Location.X, picturebox1.Location.Y + picturebox1.Height);
}
else
{
picturebox4.Width = (this.Width - picturebox1.Location.x) - (this.Width - picturebox3.Location.X - picturebox1.Width );
picturebox4.Location = new Point(picturebox1.Location.X, picturebox1.Location.Y + picturebox1.Height);
}
}
else if (picturebox2.Visible = true)
{
if (picturebox2.Visible = false)
{
}
else if (picturebox3.Visible = false)
{
picturebox4.Width = (this.Width - picturebox2.Location.x) - (this.Width - picturebox2.Location.X - picturebox2.Width);
picturebox4.Location = new Point(picturebox2.Location.X, picturebox2.Location.Y + picturebox2.Height);
}
else
{
picturebox4.Width = (this.Width - picturebox2.Location.x) - (this.Width - picturebox3.Location.X - picturebox2.Width);
picturebox4.Location = new Point(picturebox2.Location.X, picturebox2.Location.Y + picturebox2.Height);
}
}
else if (picturebox3.Visible = true)
{
picturebox4.Width = (this.Width - picturebox3.Location.x) - (this.Width - picturebox3.Location.X - picturebox3.Width);
picturebox4.Location = new Point(picturebox3.Location.X, picturebox3.Location.Y + picturebox3.Height);
}
else
{
MessageBox.Show("3个图片都没有显示");
}