Windows Forms C# application - Automatically handle DPI Scaling when a user sets the display to 125% or 150%

Srinivas Kamalanathan Attipattu 1 Reputation point
2020-12-07T06:29:03.803+00:00

We had designed a Windows Form application such that it is suitable for all the resolutions. We came across a situation where the applications appear to be incorrectly sized when the user chooses 125% or 150% in the machine display setting . I have set the screen resolution to 1440x900 and changed the setting to 125% as shown in screenshot below
45644-displaysettings.png

After making these settings to the machine and running the application, we found that the application appear to be incorrectly sized and the controls are getting overlapped with the other controls in the application

Can you please suggest any code/process for detecting the display settings i.e above 100% and handle the applications such that it appears correctly?

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,863 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,483 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 82,326 Reputation points
    2020-12-07T08:21:42.577+00:00

  2. Daniel Zhang-MSFT 9,621 Reputation points
    2020-12-08T05:22:11.79+00:00

    Hi SrinivasKamalanathanAttipattu-9545,
    First, you should change the AutoScaleMode of Form to the Dpi which Specifies the different types of automatic scaling modes supported by Windows Forms.
    Then you can try to use dock and anchor properties to auto resize and adjust Form controls.
    Here some related threads you can refer to.
    Windows Forms DPI scaling
    Creating a DPI-Aware Application
    Automatic scaling in Windows Forms
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.