当表单宽度增加时如何更改ListView的宽度?
我有一个带有 2 个 ListView 的简单表单。当我运行该程序时,它会以默认尺寸打开表单以及两个列表视图:
http: //img838.imageshack.us/img838/6123/form1default.png
我需要做的是当表单展开时(仅在宽度,我希望高度固定)第二个(更宽的)列表视图的宽度也增加:
http://img269.imageshack.us/img269/4879/form1widthincrease.png
你能告诉我什么吗我必须更改表单本身和/或第二个列表视图的属性才能实现此目的?也许还应该考虑添加一些事件?
谢谢!
I have a simple form with 2 ListViews. When I run the program it opens in default size for form and also for two listviews:
http://img838.imageshack.us/img838/6123/form1default.png
What I need to do is when the form gets expanded (only in WIDTH, I want the height be fixed) the second (wider) listview also be increased in width:
http://img269.imageshack.us/img269/4879/form1widthincrease.png
Can you pleae tell me what properties of form itself and/or second listview I have to change to achive this? Maybe some Events should be considered to add also?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过设置
Anchor 来实现此目的
第二个ListView
属性包含AnchorStyles.Right
,例如 Visual Studio 属性窗口中的Top、Left、Right
。您可能还需要包含
AnchorStyles.Bottom
,以便在表单高度更改时调整ListView
的大小。You can achieve this by setting the
Anchor
property of the secondListView
to includeAnchorStyles.Right
, e.g.Top, Left, Right
in the properties window in Visual Studio.You might also want to include
AnchorStyles.Bottom
, to resize theListView
(s) when the height of the form changes.最好将两个列表视图放在 SplitContainer 控件中并调整两个列表视图的宽度。使用 SplitContainer 的 Anchor 属性根据表单增加其宽度。
Better you put the two list views in a SplitContainer control and adjust the widths of two listviews. Use the Anchor property of the SplitContainer to increase its width according to the form.