在 winforms 应用程序中调整主窗体的大小时,如何调整面板的大小? [英] How do I resize my panels when resizing the main form in a winforms application?

查看:52
本文介绍了在 winforms 应用程序中调整主窗体的大小时,如何调整面板的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的 winforms 应用程序的用户调整主窗体的大小,我希望 2 个面板和子控件一起伸展.

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.

我怎样才能做到这一点?

How can I achieve this?

推荐答案

如果我的 winforms 应用程序的用户调整主窗体的大小,我想要 2面板也可以伸展,以及子控件.

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.

您是 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:

这篇关于在 winforms 应用程序中调整主窗体的大小时,如何调整面板的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆