C# 调整窗体大小后定位控件
我正在使用 C# 开发一个小型电影数据库程序。我在面板容器顶部有一堆动态添加的 PictureBox 对象。我通过更改 X、Y 值来控制它们的位置。默认情况下,我一行中有 3 个图片框对象。问题是,当我调整表单大小时,图像的位置保持不变,但是我正在寻找的行为是在每行中存储更多 PictureBox 控件。
将每颗星星视为一个图像。
9 图片框;
* * *
* * *
* * *
我想要的是,根据表单大小,在一行中存储更多图像。 于是就变成了这样;
* * * *
* * * *
*
除了Panel之外还有其他容器有这样的功能吗?
谷歌图片也有类似的行为。 谢谢
I'm working on a small movie database program using C#. I have bunch of dynamically added PictureBox objects located on top of a Panel container. I control their location by changing their X, Y values. By default I have 3 picturebox objects in one row. The problem is, when I resize the form, the positions of the images stay the same, however the behavior I'm looking for is, storing more PictureBox controls in each row.
Think each star as an image.
9 PictureBox;
* * *
* * *
* * *
What I want is, based on the form size, store more images in one row.
So it becomes this;
* * * *
* * * *
*
Is there any other container other than panel has such feature?
Google images has a similar behavior.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
ImageList
并将它们放置在ListView
中,ListView
会自动对它们进行排序,否则使用PictureBox.Anchor
。PS:ComponentOne 有一个名为 Sizer 的控件。ComponentOne
Use
ImageList
and place them inListView
,ListView
will automatically order them ,otherwise play withPictureBox.Anchor
.PS: ComponentOne has a Control named Sizer .ComponentOne
看一下 FlowLayoutPanel。
http://msdn.microsoft.com/en-us /library/system.windows.forms.flowlayoutpanel.aspx
Take a look at FlowLayoutPanel.
http://msdn.microsoft.com/en-us/library/system.windows.forms.flowlayoutpanel.aspx