UseCompatibleTextRendering 属性在设置为 false 时不是由设计器创建的 [英] UseCompatibleTextRendering property not created by designer when it is set to false

查看:30
本文介绍了UseCompatibleTextRendering 属性在设置为 false 时不是由设计器创建的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想使用兼容的文本渲染,但我不想使用

Application.SetCompatibleTextRenderingDefault(false);

当然,我认为我所要做的就是将每个标签的 UseCompatibleTextRendering 属性设置为 false.但是,如果 UseCompatibleTextRendering 设置为 true,则表单设计器显然只生成用于设置属性的代码.

没问题,我想,这一定意味着默认情况下 UseCompatibleTextRendering 被初始化为 false.然而,当我启动我的表单时,瞧,我看到了丑陋的 CompatibleTextRendering.所以,一个问题:

1) 为什么在我将 UseCompatibleTextRendering 设置为 false 时设计者不为 UseCompatibleTextRendering 添加代码,而当我将它设置为 true 时它,如果默认值为 true?

解决方案

设计者没有添加将UseCompatibleTextRendering设置为false的代码,因为false 是默认值.

那么,为什么控件默认使用兼容的文本呈现,如果属性的默认值是false,那似乎……很奇怪?好吧,Application.SetCompatibleTextRenderingDefault 方法将给定的值赋给 Control 类中的一个静态字段,Control 类的静态构造函数将这个字段初始化为 true.>

因此,删除行 Application.SetCompatibleTextRenderingDefault(false); 将导致应用程序使用兼容的文本呈现,这与您基于 UseCompatibleTextRendering<的默认值可能认为的相反/code> 属性.

我能看到的唯一合理的解决方案是简单地将自动生成的调用留在 Application.SetCompatibleTextRenderingDefault 原处.

I do not wish to use compatible text rendering, but I do not wish to use

Application.SetCompatibleTextRenderingDefault(false);

Naturally, I thought all I had to do was set each label's UseCompatibleTextRendering property to false. The Forms Designer, however, apparently only generates code to set the property if UseCompatibleTextRendering is set to true.

No problem, I thought, that must mean that UseCompatibleTextRendering is initialized to false by default. Yet when I start up my form, lo and behold, I see ugly CompatibleTextRendering. So, a question:

1) Why on earth isn't the designer adding code for UseCompatibleTextRendering when I set it to false and it is when I set it to true, if the default is true?

解决方案

The designer does not add code for setting UseCompatibleTextRendering to false, because false is the default value.

So, why do the controls use compatible text rendering by default, if the default value of the property is false, that seems to be... odd? Well, the Application.SetCompatibleTextRenderingDefault method assigns the given value to a static field in the Control class, and the static constructor of the Control class initializes this field to true.

So, removing the line Application.SetCompatibleTextRenderingDefault(false); will cause the application to use compatible text rendering, contrary to what you might think based on the default value of the UseCompatibleTextRendering property.

The only reasonable solution that I can see is to simply leave the automatically generated call to Application.SetCompatibleTextRenderingDefault where it is.

这篇关于UseCompatibleTextRendering 属性在设置为 false 时不是由设计器创建的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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