在.net2.0中增加了很多新的内容,比如:Application.SetCompatibleTextRenderingDefault方法。
但是,在VS2005附带的MSDN2005中却没有它的详细说明。为此,我查找了MSDN官方网站和MSDN2005的相关属性,获悉了该方法的部分信息。现将其记录如下。
一、相关链接
1.MSDN网站有Application.SetCompatibleTextRenderingDefault的详细说明,地址:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.setcompatibletextrenderingdefault(VS.80).aspx
2.MSDN2005的相关属性UseCompatibleTextRendering,地址:ms-help://MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.NETDEVFX.v20.chs/CPref17/html/P_System_Windows_Forms_ButtonBase_UseCompatibleTextRendering.htm
二、总结
1.作用:在应用程序范围内设置控件显示文本的默认方式(可以设为使用新的GDI+ , 还是旧的GDI)
true使用GDI+方式显示文本,
false使用GDI方式显示文本.
2.只能在单独运行窗体的程序中调用该方法;不能在插件式的程序中调用该方法.
3.只能在程序创建任何窗体前调用该方法,否则会引发InvalidOperationException异常.
三、MSDN网站对Application.SetCompatibleTextRenderingDefault方法的说明
Note: This method is new in the .NET Framework version 2.0.
Sets the application-wide default for the UseCompatibleTextRendering property defined on certain controls.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
![](https://i-blog.csdnimg.cn/blog_migrate/99520cb8a000b05c87b411ec88865dac.png)
![](https://i-blog.csdnimg.cn/blog_migrate/91eb71315f0d4b3fbe250187b0b57ba1.png)
Public Shared Sub SetCompatibleTextRenderingDefault ( _ defaultValue As Boolean _ )
![](https://i-blog.csdnimg.cn/blog_migrate/91eb71315f0d4b3fbe250187b0b57ba1.png)
Dim defaultValue As Boolean Application.SetCompatibleTextRenderingDefault(defaultValue)
![](https://i-blog.csdnimg.cn/blog_migrate/91eb71315f0d4b3fbe250187b0b57ba1.png)
public static function SetCompatibleTextRenderingDefault ( defaultValue : boolean )
Parameters
-
defaultValue
-
The default value to use for new controls. If true, new controls that support UseCompatibleTextRendering use GDI+ for text rendering; if false, new controls use GDI+.
![](https://i-blog.csdnimg.cn/blog_migrate/99520cb8a000b05c87b411ec88865dac.png)
Exception type | Condition |
---|---|
You can only call this method before the first window is created by your Windows Forms application. |
![](https://i-blog.csdnimg.cn/blog_migrate/99520cb8a000b05c87b411ec88865dac.png)
Certain Windows Forms controls can render their text using either the GDI graphics library, or the newer GDI+ library. This change was made because of performance and localization issues with GDI+. By default, existing controls that support the UseCompatibleTextRendering property are set to true for backwards compatibility, but all new controls in environments such as Visual Studio have this property set to false. Use SetCompatibleTextRenderingDefault when you wish to switch the default text rendering for new controls.
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.
this page![](https://i-blog.csdnimg.cn/blog_migrate/99520cb8a000b05c87b411ec88865dac.png)
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
![](https://i-blog.csdnimg.cn/blog_migrate/99520cb8a000b05c87b411ec88865dac.png)
.NET Framework
Supported in: 2.0![](https://i-blog.csdnimg.cn/blog_migrate/99520cb8a000b05c87b411ec88865dac.png)