SizeToContent相当于一个WinForm? [英] SizeToContent equivalent for a WinForm?

查看:305
本文介绍了SizeToContent相当于一个WinForm?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在与WPF玩,我发现了 SizeToContent 方法,这使我动态地创建一个窗口的内容,然后让它自动调整大小以适合其内容。

When playing with WPF, I discovered the SizeToContent method, which enables me to create dynamically the content of a window, and then have it automatically resized to fit its content.

我尝试使用的WinForms做同样的事情,它失败。

I try to do the same thing using WinForms, and it fails.

我用自动调整大小 AutoSizeMode ,但它不能正确的大小,以它的内容。

I used the AutoSize and AutoSizeMode, but it fails to correctly size to its content.

有没有一种方法来创建具有适应其内容的大小控制一个WinForm,如在WPF?

Is there a way to create a WinForm with controls that adjust to the size of their content, as in WPF?

谢谢

推荐答案

据我记得这是一个有点棘手,Windows窗体。基本上你需要使用自动调整大小容器(如TableLayoutPanel中,等 - 和他们的自动调整大小属性设置为)在专门的形式。铺设了控制与码头不起作用。

As far as I remember this is a bit tricky in Windows Forms. Basically you need to use auto-sizing containers (e.g. TableLayoutPanel, etc. – and set their AutoSize property to true) in the form exclusively. Laying out controls with Anchor and Dock does not work.

这篇关于SizeToContent相当于一个WinForm?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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