visual studio 2005 designer moves controls and resizes Form

后端 未结 10 1073
Happy的楠姐
Happy的楠姐 2020-11-29 09:36

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 cha

相关标签:
10条回答
  • 2020-11-29 10:00

    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)

    0 讨论(0)
  • 2020-11-29 10:05

    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.

    0 讨论(0)
  • 2020-11-29 10:08

    I have been working on this problem for most of today and found some interesting things: The main source of the problem seems to be relying on anchoring. If I use docking to position my controls, instead of anchoring, my problems seem to go away. I found a couple of blog posts from 2003(!), which detail how you might use docking instead of anchoring, and explain how anchoring can break the Windows Forms designer. It seems like this problem might be over 7 years old!

    Here are the posts:

    • http://weblogs.asp.net/rweigelt/archive/2003/09/24/28984.aspx
    • http://weblogs.asp.net/rweigelt/archive/2003/10/17/32407.aspx
    • http://weblogs.asp.net/rweigelt/archive/2003/10/23/33181.aspx
    0 讨论(0)
  • 2020-11-29 10:09

    This is one you should live with. Even in VS2008 such things happen from time to time. It is mostly depends on form content (controls, positions, etc), and there is no option in VS to disable such behavior.

    When you open your form in designer, vs runtime rebuilds visual appearance from code behind. And sometimes it made changes at this moment. Also when you are simply adding one control to form, designer fully rebuilds codebehind and resource files. This is well known issue, and seems that MS won't fix it, because they move in WPF direction.

    So several points to simplify your life:

    1. Move to VS2008, designer were more consistent, but still shuffle controls in .designer.cs file
    2. Place your code in one of the source repositories, so if you accidentally saved such form, you can restore it from repositary.
    0 讨论(0)
提交回复
热议问题