4

I recently updated my development workstation to Windows 8.1 with a 4K monitor and went from Visual Studio 2010 to 2012. When I opened an existing project sweeping changes were made to Margin and Padding (were default).

Label - Margin(8, 0, 8, 0)
Button, DataGridView, TextBox, CheckBox - Margin(8, 7, 8, 7)
MenuStrip - Padding(16, 5, 0, 5)
GroupBox - Margin(8, 7, 8, 7) and Padding(8, 7, 8, 7)

The control Sizes are also bigger than before.

Is this because I'm using a 4K monitor with display scaling? If so, how can I control layout with this setup. Do I have to change my display resolution every time I want to edit the form?

Or is it something to do with VS 2012 or Win 8.1?

Any help is appreciated.

Jim Balkwill
  • 328
  • 5
  • 12

1 Answers1

3

The answer relates to DPI scaling. Basically, when something is edited in the designer other than at 96 DPI, it is scaled. When you save, the scaled values are saved. I was editing a form at 150 DPI.

I find the DPI support in Winforms to be pretty awkward but the wisdom seems to be to use the designer at a consistent DPI - i.e. on the same monitor and preferably at 96 DPI.

I have certainly found that it is difficult to get layout correct at higher DPI. I just can't see if things are properly aligned at higher DPI whereas I can see it clearly at 96 DPI. So, whether the advice to stick to 96 DPI is technically required or not I can't confirm but as a practice I find it visually necessary.

Here are some answers about how to build DPI Aware applications: https://stackoverflow.com/a/13228495/1439940, https://stackoverflow.com/a/4076259/1439940, https://stackoverflow.com/a/202172/1439940

Community
  • 1
  • 1
Jim Balkwill
  • 328
  • 5
  • 12