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.
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.)
Some helpful links on using it to configure your layout to scale:
您可以使用 TableLayoutPanel 并将列宽设置为 x%,这样您就可以将屏幕分成 2 部分。TableLayoutPanel 必须是 Dock 才能填充所有表单或 Anchor。
TableLayoutPanel 可以包含其他面板。 或者您可以简单地使用面板并使用 Anchor(单击面板并进入 VS 的“属性”面板)。
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.
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).
发布评论
评论(3)
您是 TableLayoutPanel 的理想用例(MSDN)。 如果您只是缩放面板,Dock 和 Anchor 就比较合适。 但由于您希望控件能够很好地缩放,因此您几乎处于 AutoLayout 世界中,并且可能处于 TableLayoutPanel 世界中。 (顺便说一句,我是这个的忠实粉丝,尽管过度使用会对控件的布局产生负面的性能影响。)
有关使用它来配置布局以进行缩放的一些有用链接:
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.)
Some helpful links on using it to configure your layout to scale:
尝试使用面板的Dock 和Anchor 属性。
Play around with the Dock and Anchor properties of your panels.
您可以使用 TableLayoutPanel 并将列宽设置为 x%,这样您就可以将屏幕分成 2 部分。TableLayoutPanel 必须是 Dock 才能填充所有表单或 Anchor。
TableLayoutPanel 可以包含其他面板。 或者您可以简单地使用面板并使用 Anchor(单击面板并进入 VS 的“属性”面板)。
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.
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).