如何自动调整选项卡控件周围表单的大小更多控制
我有一个包含多个控件的表单:
ProgressBar
位于表单顶部(停靠)- 一个
TabControl
位于表单顶部(也停靠在进度栏下方) TabControl
的TabPages
内的Button
、TextBoxes
和labels
FlowLayoutPanel< /code> 位于屏幕底部(停靠),其中有几个按钮
Label
位于表单底部,用作分隔符(也停靠,但位于FlowLayoutPanel
上方>)
我正在尝试自动调整表单大小以适应其内容。需要发生的是:
- 选项卡页环绕其内容
- 选项卡控件环绕最大的选项卡页
- 表单环绕选项卡控件、进度条和按钮。
以下示例展示了没有将 AutoSizeMode
设置为 GrowAndShrink
(仅 Grow
)时表单的外观:
替代文本 http://www.fusyion.net/images/Form%20no%20shrink.png< /a>
这就是 AutoSizeMode
设置为 GrowAndShrink
的样子:
替代文本 http://www.fusyion.net/images/Form%20with%20shrink.png
请告知。
I have a form that has several controls:
ProgressBar
at the top of the form (docked)- A
TabControl
at the top of the form (also docked but underneath the progress bar) Buttons
,TextBoxes
andlabels
insideTabPages
of theTabControl
FlowLayoutPanel
at the bottom of the screen (docked) with a few buttons in itLabel
at the bottom of the form to act as separator (also docked, but above theFlowLayoutPanel
)
I am trying to auto size the form to fit its content. What needs to happen is:
- Tab pages wrap around its content
- Tab control wraps around the largest tab page
- The form wraps around the tab control, progress bar and buttons.
Here's an example of how the form looks without AutoSizeMode
set to GrowAndShrink
(just Grow
):
alt text http://www.fusyion.net/images/Form%20no%20shrink.png
And this is how it looks with AutoSizeMode
set to GrowAndShrink
:
alt text http://www.fusyion.net/images/Form%20with%20shrink.png
Please advise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保表单的直接子级将锚点精确设置为
Left
和Top
。您可以设置 Form.MinimumSize 属性 和 Form.MaximumSize 属性 作为预防措施。Make sure the direct children of your form have anchors set exactly to
Left
andTop
. You could set the Form.MinimumSize Property and Form.MaximumSize Property as a precaution.要使其正常工作,您必须将所有控件的
MinimumSize
设置为一个值。收缩模式将遵循这一点,从而形成尺寸合适的形状。To get this to work, you have to set the
MinimumSize
of all your controls to a value. This will be respected from the Shrink-Mode, thus leading to a well sized form.