How to auto size a form around a tab control + more controls
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 co开发者_Python百科ntrol 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.
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.
Make sure the direct children of your form have anchors set exactly to Left
and Top
. You could set the Form.MinimumSize Property and Form.MaximumSize Property as a precaution.
精彩评论