Controls moving in vs2008 design mode on build

℡╲_俬逩灬. 提交于 2020-01-23 23:10:35

问题


I have a C#.NET winforms project, and some controls are moving in design view whenever I build the project. Its only some of the controls (a panel with a label and datagridview in it, a button, a link button and a label) are all moving up on each build.

Has anyone seen this before or know how to fix it?


回答1:


I think it is because of the AutoScaleDimensions. My guess is that your form was originally created on another machine.

Per MSDN.

"The AutoScaleDimensions property represents the DPI or font setting of the screen that the control was scaled to or designed for. Specifically, at design time this property will be set by the Windows Forms designer to the value your monitor is currently using. Then, when the form loads at run time, if the CurrentAutoScaleDimensions property is different from the AutoScaleDimensions, the PerformAutoScale method will be called to perform scaling of the control and all of its children. Afterwards, AutoScaleDimensions will be updated to reflect the new scaling size."

My guess is that for odd some reason when you build you project property (maybe some others) gets adjusted, but not on design time. I think about few possible reasons:

  • You work on multiple monitors and/or there is some odd stuff with your adapter.

  • There is some problem with auto-generated designer file. Maybe it
    edited manually somehow.

To fix I propose to do something I would do:

  • Recreate form from scratch if possible, by copy-pasting bits one-by-one.

  • If not take some merging tool and insert fresh form properties.

Also here is another interesting question on AutoScaleDimentions.



来源:https://stackoverflow.com/questions/9776698/controls-moving-in-vs2008-design-mode-on-build

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