Label.UseCompatibleTextRendering Label.UseCompatibleTextRendering Label.UseCompatibleTextRendering Label.UseCompatibleTextRendering Property


获取或设置一个值,该值确定是使用 Graphics 类 (GDI+GDI+) 还是 TextRenderer 类 (GDIGDI) 呈现文本。Gets or sets a value that determines whether to use the Graphics class (GDI+GDI+) or the TextRenderer class (GDIGDI) to render text.

 property bool UseCompatibleTextRendering { bool get(); void set(bool value); };
public bool UseCompatibleTextRendering { get; set; }
member this.UseCompatibleTextRendering : bool with get, set
Public Property UseCompatibleTextRendering As Boolean


trueGraphics如果类应用于执行文本呈现, 以便与版本1.0 和1.1 兼容, 则为。true if the Graphics class should be used to perform text rendering for compatibility with versions 1.0 and 1.1. .NET Framework 的;否则为falseof the .NET Framework; otherwise, false. 默认值为 falseThe default is false.


属性旨在提供TextRenderer使用.NET Framework 1.0.NET Framework 1.0.NET Framework 1.1.NET Framework 1.1呈现文本的 Windows 窗体控件与使用执行自定义文本呈现的应用程序之间的视觉兼容性UseCompatibleTextRendering Graphics类。The UseCompatibleTextRendering property is intended to provide visual compatibility between Windows Forms controls that render text using the TextRenderer class and .NET Framework 1.0.NET Framework 1.0 and .NET Framework 1.1.NET Framework 1.1 applications that perform custom text rendering using the Graphics class. 在大多数情况下, 如果你的应用程序未从.NET Framework 1.0.NET Framework 1.0.NET Framework 1.1.NET Framework 1.1升级, 则建议你UseCompatibleTextRendering将设置为的默认值falseIn most cases, if your application is not being upgraded from .NET Framework 1.0.NET Framework 1.0 or .NET Framework 1.1.NET Framework 1.1, it is recommended that you leave UseCompatibleTextRendering set to the default value of false.

中引入TextRenderer.NET Framework 2.0.NET Framework 2.0基于的类, 以便提高性能, 使文本更好地显示, 并改善对国际字体的支持。 GDIGDIThe GDIGDI based TextRenderer class was introduced in the .NET Framework 2.0.NET Framework 2.0 to improve performance, make text look better, and improve support for international fonts. 在的.NET Framework.NET Framework早期版本中, 使用了Graphics基于的GDI+GDI+类来执行所有文本呈现。In earlier versions of the .NET Framework.NET Framework, the GDI+GDI+ based Graphics class was used to perform all text rendering. GDIGDI以不同于的GDI+GDI+方式计算字符间距和自动换行。calculates character spacing and word wrapping differently from GDI+GDI+. 在使用Graphics类呈现文本的 Windows 窗体应用程序中, 这可能会导致使用TextRenderer的控件的文本与应用程序中的其他文本显示不相同。In a Windows Forms application that uses the Graphics class to render text, this could cause the text for controls that use TextRenderer to appear different from the other text in the application. 若要解决这种不兼容性问题UseCompatibleTextRendering , 可以true将特定控件的属性设置为。To resolve this incompatibility, you can set the UseCompatibleTextRendering property to true for a specific control. 若要UseCompatibleTextRendering true为应用程序中的所有受支持的控件设置Application.SetCompatibleTextRenderingDefault , 请使用参数true调用方法。To set UseCompatibleTextRendering to true for all supported controls in the application, call the Application.SetCompatibleTextRenderingDefault method with a parameter of true.