Visual Studio Designer added margin and padding to my form

后端 未结 1 669
小鲜肉
小鲜肉 2020-12-10 19:32

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 w

相关标签:
1条回答
  • 2020-12-10 20:02

    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

    0 讨论(0)
提交回复
热议问题