使控件及其字体变大
我有一个表单,在旧的 winForms 应用程序中有很多控件 客户说他使用低屏幕分辨率来轻松管理此表单
,现在他希望无论屏幕分辨率如何,控件和字体大小都很大,
如果这不是一个简单的过程,我可以从什么开始吗?
I have a form which have so many controls in an old winForms App
the client said he's using low screen resolution to easily manage this form
and now he want the controls and there font size to be big regardless of the screen resolution
if it's not an easy process is there any thing i can start with ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将其放入表单的 OnLoad 覆盖或 Load 事件处理程序中:
这利用了 AutoScaleMode 属性配置的内置自动缩放功能。这是否会保持布局完整是无法猜测的,你必须尝试一下。
您的客户也可以通过增加视频适配器的 DPI 设置来实现此目的。在 Vista 及更高版本中,超过 125% (120 dpi) 会触发兼容的 DPI 缩放。这使得操作系统谎报 DPI 设置并通过位图缩放生成更大的窗口。使其变得模糊但足够大以可用。
Put this in the form's OnLoad override or Load event handler:
Which takes advantage of the built-in autoscaling as configured by the AutoScaleMode property. Whether that will keep the layout intact is a unguessable, you'll have to try.
Your customer can do this too by increasing the video adapter's DPI setting. On Vista and up, going past 125% (120 dpi) triggers compatible DPI scaling. Which makes the OS lie about the DPI setting and produces a larger window through bitmap scaling. Makes it fuzzy but big enough to be usable.
您可以更改每个控件的样式,也可以创建一个样式类并更改控件以使用它,如以下链接所示: http://www.codeproject.com/KB/miscctrl/WinFormStyleSheet.aspx
You can change the style for each of the controls or you can create a style class and change your controls to consume it as shown in the following link: http://www.codeproject.com/KB/miscctrl/WinFormStyleSheet.aspx
大多数显示文本的 winforms 控件都有一个 FontHeight 属性,您可以修改该属性以设置该特定元素的永久字体高度。这是最灵活的解决方案,您可以控制哪些元素获得更大的字体处理。
Most winforms controls that display text have a FontHeight property which you can modify in order to set the permanent font height for that particular element. This is the most flexible solution where you can control which elements get the larger font treatment.