Winforms :: 为什么更改表单字体会调整某些控件的大小?
我的所有表单都继承自一个基本表单,我们在其中处理背景绘制并设置标准属性。
我最近考虑检查应用程序是否在 Vista 或更高版本上运行以使用 Segoe UI 字体,我添加了这一点。
问题是继承的表单改变了大小,它们的内部控件也改变了......甚至PictureBox!控件和表单看起来更薄(宽度),因此方形图片框变成了垂直矩形!
前段时间,当我从标准(?)Sans Serif 更改为 Verdana 时,发生了同样的情况,但当时我的应用程序较小,我检查并修复了每个表单......现在有数百个表单,这并不方便。
知道为什么会发生这种情况以及解决这个问题的方法是什么吗?
All my forms inherit from one base form where we handle background paint and set standard properties.
I recently considered checking if the app is running on Vista or Later to use Segoe UI font, and I added this.
The problem is that inherited forms changed sizes and their inner controls changed also... even PictureBoxes!! The controls and forms seem thinner (in width), so the square picturebox became vertical rectangles!
Some time ago when I changed from the standard (?) Sans Serif to Verdana, the same happened but at that time my app was way smaller and I checked and fixed every form... now with hundreds of forms it is not handy.
Any idea why this happened and what could be the way to work around it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需更改 Form 的 AutoScaleMode 属性即可。默认情况下,它是字体,因此如果更改字体属性,它将调整表单的大小。您可以从 MSDN 中的 AutoScaleMode 枚举< /a>:
Just change the AutoScaleMode property of the Form. By default it will be Font, so if you change the Font property it will resize the Form. You can get more information about it from AutoScaleMode Enumeration in MSDN :