星期五, 5月 27, 2022

[C#] UseCompatibleTextRendering

在自家某自訂控件內發現有開啟 UseCompatibleTextRendering 屬性,在官方文件 - Application.SetCompatibleTextRenderingDefault(Boolean) Method 備註說明查到該說明
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 and .NET Framework 1.1 applications that perform custom text rendering using the Graphics class. In most cases, if your application is not being upgraded from .NET Framework 1.0 or .NET Framework 1.1, it is recommended that you leave UseCompatibleTextRendering set to the default value of false.
沒有向前相容需求就順道把它改回預設值就好,另外發現原來有全域設定方式,以往開啟 WinForm 程式都沒有注意過這細節
static class Program  
{  
    [STAThread]  
    static void Main()  
    {  
        Application.EnableVisualStyles();  
        Application.SetCompatibleTextRenderingDefault(false); // 全域設定
        Application.Run(new Form1());  
    }  
}  

沒有留言:

張貼留言