简体   繁体   中英

Windows Forms C# application - Set font size of form controls to fit the screen when a user choose 125% or 150% for the OS font size?

We had designed a Windows Form application such that it is suitable for all the resolutions. We came across a situation where the font size of all the controls in the form has increased when the user chooses 125% or 150% for the font size. I have set the screen resolution to 1440x900 and changed the setting to 125% as shown in screenshot below

在此处输入图像描述

After making these settings to the machine and running the application, we found that the font size of all the controls in the form has increased and it is getting overlapped with the other controls.

Can you please suggest any code/process for detecting the increase in OS font size ie above 100% and handle the size of the fonts for the controls?

I'd first try using

System.Drawing.SystemFonts.DefaultFont

for all form elements. AutoScale.Dpi may cause some weird changes to your UI when using different monitors, scales and resolutions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM