Label.UseCompatibleTextRendering 属性


获取或设置一个值,该值确定是使用 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



true 如果 Graphics 类应用于执行文本呈现,以便与版本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.


UseCompatibleTextRendering属性旨在提供使用类呈现文本的 Windows 窗体控件与 TextRenderer .NET Framework 1.0.NET Framework 1.0 .NET Framework 1.1.NET Framework 1.1 使用类执行自定义文本呈现的应用程序之间的视觉兼容性 GraphicsThe 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.

GDIGDI中引入了基于的 TextRenderer.NET Framework 2.0.NET Framework 2.0 ,以便提高性能,使文本更好地显示,并改善对国际字体的支持。The 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 FrameworkGDI+GDI+ 使用了基于的 Graphics 类来执行所有文本呈现。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+. 在使用类呈现文本的 Windows 窗体应用程序中 Graphics ,这可能会导致使用的控件的文本与 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 特定控件的属性设置为 trueTo resolve this incompatibility, you can set the UseCompatibleTextRendering property to true for a specific control. 若要 UseCompatibleTextRendering true 为应用程序中的所有受支持的控件设置,请 Application.SetCompatibleTextRenderingDefault 使用参数调用方法 trueTo set UseCompatibleTextRendering to true for all supported controls in the application, call the Application.SetCompatibleTextRenderingDefault method with a parameter of true.