0

I'm working on a VB.NET WinForms app (.NET Framework 4.8) and seeing inconsistent scaling between forms. I develop on my work laptop using a Remote Desktop Connection.

This problem began when I changed the "System > Display > Scale" on my local PC.

I now have:

  • Local PC: 200%
  • Remote laptop (RDP): 100%

After making those changes, the app/parent form appears correct on the remote machine — until I load certain child forms.

  • One child form loads normally and does not affect scaling
  • Another child form causes the parent form to rescale to ~ 50% (i.e., 100 / 200)

GIF showing scaling issue in WinForms app

I added this to app.config:

<system.windows.forms.applicationConfigurationSection>
    <add key="DpiAwareness" value="PerMonitorV2" />
</system.windows.forms.applicationConfigurationSection>

I have since manually normalized all forms to:

AutoScaleDimensions = New SizeF(96.0!, 96.0!)
AutoScaleMode = AutoScaleMode.Dpi

Note: the AutoScaleDimensions property appears to change automatically when modifying forms using the designer while the scales differ. It also seems to apply a scale factor to the Me.ClientSize property based on the form's overall Me.Size.

E.g.

Me.ClientSize = New System.Drawing.Size(990, 718)

This cannot be normalized since all of my forms' Size values vary.

This seems to work as long as both systems are scaled to 100% but breaks when they are different.

Question

What is the proper way to ensure consistent DPI scaling in a WinForms app based on each users' system settings?

Edit

This is a legacy application built using Visual Studio 2017 targeting .NET Framework 4.8.

One additional detail that may be relevant: the scaling issue only occurs with some child forms, while others load and behave correctly without affecting the parent form’s scaling. This inconsistency suggests that certain child forms may inherit from different base classes or have differing scaling-related configurations (e.g., AutoScaleMode, AutoScaleDimensions, or DPI awareness settings), which could be contributing to the problem.

5
  • You should design at 100% scale. If you develop on two or more different machines which have different scale factors that you cannot changes because of policies you have no control over, you can try disabling the DPI Awareness of Visual Studio 2022 17.8+ itself (the .NET Framework's WinForms Designer is DPI unaware in any case). The Project's setting for this applies to the .NET 6+ model, though, but you can try starting devenv.exe with a command switch. See here for more information Commented Mar 27 at 20:19
  • Thank you @Jimi. I failed to mention that this is a legacy app using VS2017 and .NET Framework 4.8 (added to question). I did read a couple of articles that also suggested keeping a dedicated UI design environment set at 100%—good call. If I simply set both scales to 100% then run the application, the issue still persists. I'm wondering if I need to open each forms' designer to force the designer to update the ClientSize properties. Commented Mar 28 at 19:02
  • With .NET Framework, unwanted scaling may occur for different reasons. For example, you scale the System's screen after booting. If you have PresentationFramework (WPF) elements in some classes, then the app is scaled according to the SystemAware model (resolution set at System's boot time). See here for more info (read to the end). If some of your Forms could have a different AutoScaleMode set (at 100% scale), then close all Forms, remove that line from the .designer.cs files (using the find & replace utility), then reopen the Forms Commented Mar 28 at 22:18
  • Do you know if I should just remove the AutoScaleMode rows, or should I also remove the AutoScaleDimensions and ClientSize rows as well? Thanks. Commented 2 days ago
  • Nope, that was a typo on my side, sorry for that. I meant to write "remove the AutoScaleDimensions line" (not AutoScaleMode, that would be silly. Though you could also make a test setting it to None). Just that one line Commented 2 days ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.