visual studio 2005 designer moves controls and resizes Form

后端 未结 10 1072
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 09:45

    I found locking the controls from the format menu was a simple and effective solution. VS2013

    0 讨论(0)
  • 2020-11-29 09:47

    I had this issue, too. Every time I opened the designer, every box with anchor "right" was moved about 20 Pixels to the left. Additionally, the bottom of every box with anchor "left" was about 200 pixels outside the form.

    This form has many controls and should not shrink on smaller displays, so it was set to autoscroll, the form itself was smaller in the designer than the shown minimum size (historically...). I just set the size to the minimum size so that no scroll bars appeared in the designer and the anchors worked as expected without screwing up the postitions.

    I read the first post from ryantm's answer which led me to the solution. Apparently it has something to do with the order .Net executes events such as setting the size of a form.

    0 讨论(0)
  • 2020-11-29 09:48

    I had this problem with VS 2015. I used dock panels with the controls that moved unexpectedly as their childs. By default the controls will be aligned to the left, but you can change the orientation. My buttons stopped moving.

    0 讨论(0)
  • 2020-11-29 09:51

    Had the same problem with controls anchored top, left and right within complex TabControls. The visual studio forms designer was increasing the width of all nested controls each time I would open the form.

    I found a simple workaround thanks to this post. I simply added a panel to each tab and set their dock property to fill. All existing controls within the tabs were moved inside those panels. This works, even if the controls are anchored top, left and right.

    Works at least for Visual Studio 2013 and 2015.

    0 讨论(0)
  • 2020-11-29 09:53

    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.

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

    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%.

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