Why is my Visual Studio (VB.NET) layout different in Design View vs. at run-time on my home computer, but identical on my work computer?

走远了吗. 提交于 2019-12-13 22:34:26

问题


I've been developing a program with Windows Forms on my work computer in VB.NET using Visual Studio 2013. When I run it on my work computer, the forms at run-time look identical to the forms in design view - the same overall size, the same layout, etc. Here is what it looks like on my work computer - AND when I access my work computer over remote desktop from my home computer.

However, on my home computer, it looks different in design view than at run-time. The form in design view is smaller and labels are misaligned.

Both computers are running Visual Studio 2013 with the same settings. I'm working on a larger monitor at home, but the fact that things look right when I access my work computer over Remote Desktop makes me think it's not my monitor.

My work computer is Windows 7 while my work computer is Windows 8.1.

Things I've tried:

  • Anchoring/docking the labels, but the layout ends up looking wrong
  • Changing the AutoScaleMode to DPI instead of Font, but that only changes the appearance at runtime, not in design view, and it still doesn't match design view.

Any ideas?


回答1:


I figured it out! It was a setting in Windows on my home computer. (Still unclear why it looked right via Remote Desktop, but maybe it uses the remote computer's settings instead of the local one's).

The solution was:

  • Right click, choose "Screen Resolution"
  • Click "Make text and other items larger or smaller"
  • Check "Let me choose one scaling level for all my displays" and set size to "smaller - 100%"

For some reason, on my home computer the size was set to 125%.




回答2:



After searching for a solution online this worked for me:

this.AutoSize = false;<br>
this.AutoScaleMode = AutoScaleMode.Font;

I put this code on form load and the display remained the same.



来源:https://stackoverflow.com/questions/29447403/why-is-my-visual-studio-vb-net-layout-different-in-design-view-vs-at-run-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!