WinForms controls crash every time a view is viewed

I am puzzled by some strange behavior in the Visual Studio Form Editor. I saw this in several different forms in my application. Each time I open a form in the Visual Studio Layout Editor, some controls will be in a different place than when I left them. Typically, some buttons advance slightly from the lower right corner. But these are not just buttons, in one case it is a container panel that moves. I have to change them, then save and close the form. I confirmed that the layout editor actually changes the property Locationwhen the form is opened, because if I save and close the form using the buttons in the correct position, they will be correct at runtime.

This is not a problem with the correct property settings Anchoror Dock. The editor actually changes the property of Locationmy controls. I looked at the .designer.cs file and I see nothing unusual. I tried to delete and recreate these controls, but the problem persists.

Any ideas what I can do?

This is not an indicative stopper. I just need to very carefully capture the controls manually every time I open it in the winforms layout editor.

Edit: Visual Studio will actually check the file automatically to install Locationon what it stubbornly thinks it should be.

+5
source share
5 answers

, . 2003 !

: Visual Inheritance Anchoring.

: http://weblogs.asp.net/rweigelt/archive/2003/09/24/28984.aspx

+2

WinForms - WYSIWYG, , , , . , , .

. (, , ). , , , . SplitContainer MinSize Panel2 (. http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/ee6abc76-f35a-41a4-a1ff-5be942ae3425). , root, .

, . , . , "" - " ".

WPF. XAML , WYSIWYG.

+2

PaulG, , , DPI

(120 ) (96 dpi).

+1

Most likely, this is a problem associated with DPI. Check the .cs constructor for the AutoScaleMode property and try changing it (or adding it) to set the form .AutoscaleMode = Font

0
source

Try locking controls in design mode, and then see how this happens.

0
source

All Articles