System.Windows.Forms.Application.SetCompatibleTextRenderingDefault Method

Sets the application-wide default for the UseCompatibleTextRendering property defined on certain controls.

Syntax

public static void SetCompatibleTextRenderingDefault (bool defaultValue)

Parameters

defaultValue
The default value to use for new controls. If true, new controls that support UseCompatibleTextRendering use the ndptecgdiplus based System.Drawing.Graphics class for text rendering; if false, new controls use the ndptecgdi based System.Windows.Forms.TextRenderer class.

Remarks

Certain Windows Forms controls can render their text using either the System.Windows.Forms.TextRenderer class, which is based on the ndptecgdi graphics library, or the System.Drawing.Graphics class, which is based on the ndptecgdiplus graphics library. This change was made in the dnprdnlong because of performance and localization issues with ndptecgdiplus. Use Application.SetCompatibleTextRenderingDefault(bool) to set the default value of the UseCompatibleTextRendering property for controls that support it.

The UseCompatibleTextRendering property is intended to provide visual compatibility between Windows Forms controls that render text using the System.Windows.Forms.TextRenderer class and net_v10_short and net_v11_short applications that perform custom text rendering using the System.Drawing.Graphics class. In most cases, if your application is not being upgraded from net_v10_short or net_v11_short, it is recommended that you leave UseCompatibleTextRendering set to the default value of false.

The ndptecgdi based System.Windows.Forms.TextRenderer class was introduced in the dnprdnlong to improve performance, make text look better, and improve support for international fonts. In earlier versions of the dnprdnshort, the ndptecgdiplus based System.Drawing.Graphics class was used to perform all text rendering. ndptecgdi calculates character spacing and word wrapping differently from ndptecgdiplus. In a Windows Forms application that uses the System.Drawing.Graphics class to render text, this could cause the text for controls that use System.Windows.Forms.TextRenderer to appear different from the other text in the application. To resolve this incompatibility, you can set the UseCompatibleTextRendering property to true. To set UseCompatibleTextRendering to true for all supported controls in the application, call the Application.SetCompatibleTextRenderingDefault(bool) method with a parameter of true.

You should never call this method if your Windows Forms code is hosted in another application, such as Internet Explorer. Only call this method in stand-alone Windows Forms applications.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0