In .NET core WinForms controls text size changes in response to Windows Scale Text Size

  Kiến thức lập trình

In my .NET 8 C# WinForms applications, when the system text size is changed (via System->Display->Scale->Text size), most of my controls runtime font sizes change (except for textbox for some reason). None of my control font sizes are set explicitly in code. I noticed the same behavior in .NET 7.

When my applications were .NET framework 4.8, this behavior did not occur (font sizes for all controls was unaffected by Scale->Text size changes and the designer code was identical to the .NET 8 version).

My forms are all set to AutoScaleMode=Dpi in .NET 8 (same as under framework 4.8).

For .NET 8, I use:

Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);

LEAVE A COMMENT