If the user of my winforms application resizes the main form, I want the 2 panels to stretch out also, along with the child controls.
如果我的winforms应用程序的用户调整了主窗体的大小,我希望2个面板与子控件一起伸展。
How can I achieve this?
我怎样才能做到这一点?
3 个解决方案
#1
10
If the user of my winforms application resizes the main form, I want the 2 panels to stretch out also, along with the child controls.
如果我的winforms应用程序的用户调整了主窗体的大小,我希望2个面板与子控件一起伸展。
You're the ideal use case for TableLayoutPanel (MSDN). If you were only scaling the panels, Dock and Anchor would be appropriate. But since you want your controls to scale well, you're pretty much in an AutoLayout world, and likely the TableLayoutPanel. (I'm a huge fan of this, by the way, although overuse can have a negative performance impact on laying out your controls.)
您是TableLayoutPanel(MSDN)的理想用例。如果您只是缩放面板,Dock和Anchor是合适的。但是,既然你希望你的控件能够很好地扩展,那么你几乎处于AutoLayout世界,而且很可能是TableLayoutPanel。 (顺便说一句,我对此非常喜欢,尽管过度使用会对布局控件产生负面的性能影响。)
Some helpful links on using it to configure your layout to scale:
使用它来配置布局以扩展的一些有用链接:
- AutoLayout By Examples
- WinForms AutoLayout Basics: TableLayoutPanel
- Video Training on TableLayoutPanel
AutoLayout通过示例
WinForms AutoLayout基础知识:TableLayoutPanel
TableLayoutPanel上的视频培训
#2
4
Play around with the Dock and Anchor properties of your panels.
使用面板的Dock和Anchor属性。
#3
3
You can use the TableLayoutPanel and set column width at x% each this way you will have the screen split in 2. The TableLayoutPanel must be Dock to fill all the form or Anchor.
您可以使用TableLayoutPanel并将列宽设置为x%,每次将屏幕拆分为2. TableLayoutPanel必须为Dock才能填充所有表单或Anchor。
The TableLayoutPanel can contain other panel. OR you can use simply your panel and use Anchor (click the panel and go in the Properties panel of VS).
TableLayoutPanel可以包含其他面板。或者您只需使用面板并使用锚点(单击面板并进入VS的“属性”面板)。
#1
10
If the user of my winforms application resizes the main form, I want the 2 panels to stretch out also, along with the child controls.
如果我的winforms应用程序的用户调整了主窗体的大小,我希望2个面板与子控件一起伸展。
You're the ideal use case for TableLayoutPanel (MSDN). If you were only scaling the panels, Dock and Anchor would be appropriate. But since you want your controls to scale well, you're pretty much in an AutoLayout world, and likely the TableLayoutPanel. (I'm a huge fan of this, by the way, although overuse can have a negative performance impact on laying out your controls.)
您是TableLayoutPanel(MSDN)的理想用例。如果您只是缩放面板,Dock和Anchor是合适的。但是,既然你希望你的控件能够很好地扩展,那么你几乎处于AutoLayout世界,而且很可能是TableLayoutPanel。 (顺便说一句,我对此非常喜欢,尽管过度使用会对布局控件产生负面的性能影响。)
Some helpful links on using it to configure your layout to scale:
使用它来配置布局以扩展的一些有用链接:
- AutoLayout By Examples
- WinForms AutoLayout Basics: TableLayoutPanel
- Video Training on TableLayoutPanel
AutoLayout通过示例
WinForms AutoLayout基础知识:TableLayoutPanel
TableLayoutPanel上的视频培训
#2
4
Play around with the Dock and Anchor properties of your panels.
使用面板的Dock和Anchor属性。
#3
3
You can use the TableLayoutPanel and set column width at x% each this way you will have the screen split in 2. The TableLayoutPanel must be Dock to fill all the form or Anchor.
您可以使用TableLayoutPanel并将列宽设置为x%,每次将屏幕拆分为2. TableLayoutPanel必须为Dock才能填充所有表单或Anchor。
The TableLayoutPanel can contain other panel. OR you can use simply your panel and use Anchor (click the panel and go in the Properties panel of VS).
TableLayoutPanel可以包含其他面板。或者您只需使用面板并使用锚点(单击面板并进入VS的“属性”面板)。