visual studio 2005 designer moves controls and res

2019-01-06 19:42发布

When i open a form in visual studio 2005 (c#) the designer automaticaly resize the form and move/resize controls without touching the designer at all. The source file is changed and when i close the designer i'm asked to save the *.cs file. I tried to look into visual studio options without any success. any ideas? visual studio setup or something? thanks, Tal

10条回答
啃猪蹄的小仙女
2楼-- · 2019-01-06 20:20

I found a work around.

not sure what happens behind but i changed my display properties. and it works fine. here is the sequence: display propertis->settings tab->advance. in the the advance dialog i changed the "DPI Settings" from Large (120dpi) to Normal (96 dpi)

查看更多
做自己的国王
3楼-- · 2019-01-06 20:23

This is due to AutoScaleMode-property. Your forms have probably been designed with a different DPI or Font settings than you have now in Windows display settings. AutoScaleMode-property has 4 different possible values : Dpi, Font, Inherit or None. In Dpi or Font mode, your forms and controls will be automatically resized depending on windows display settings.

So, set the AutoScaleMode-property to None in all your forms and controls and they won't be automatically resized anymore. Try to design your forms in order to let sufficient space in every controls so that text will fit even if text size is set to 125%.

查看更多
够拽才男人
4楼-- · 2019-01-06 20:24

Setting the form Min and Max size settings to the current size was a good work around for me. This prevented VS from resizing it.

查看更多
戒情不戒烟
5楼-- · 2019-01-06 20:29

I had a trivial form with few controls on it, where the OK and Cancel at the bottom were being shifted up as soon as the form was opened in the VS2013 designer. The same behaviour was observed in VS2015.

The accepted answer here of DPI did not solve the issue for me, nor were there any issues on the size of the form/padding/margins.

Removing the controls that are shifted and adding them back into the form solved the problem for me, as suggested by ptutt here: Visual Studio designer moving controls and adding grid columns when form is opened

While I appreciate ryantum's suggestion and links of using docking [with panels], as also referred to in the link above with Roland's blog post here https://weblogs.asp.net/rweigelt/28984, with something so trivial I'd rather just make it go away with removing/adding back in.

查看更多
登录 后发表回答