Vb.net – How to resolve Windows Forms designer issue – controls move on debug

vb.netvisual studio 2012windows-forms-designer

Is there a reason / fix for this weird designer issue (at least, I think it's related to the designer), whereby the controls on the form do not appear as they do in the design window when I debug the application..!

Please see the following two screenshots to demonstrate the problem (note: I have blacked out some of the content of the form, this is not the problem):

Picture 1: Showing how the form appears in the designer view
enter image description here

Picture 2: Showing how the form appears in debug mode
enter image description here

You can clearly see that some of the buttons have moved position on the form.

Note: At first glance, this may appear like a duplicate of: Windows Forms Designer destroys form layout. However, I have not installed any additional tools or components. This is simply a standard "vanilla" build of Visual Studio 2012 on Windows 7 32-bit.

I've also come across this question: UI Controls Overlapping & Fonts Issue in Windows Forms Application. However, I am not using "large fonts", nor am I using any non-standard fonts on my controls (all label and button text is left as default). Still, I can see how this would affect the control positions and will do some more checks in this area.

There's nothing happening within the form's Load method.

I'm also using TFS 2012.

What could be causing this? Is there anything I can do to fix it?

EDIT: I've removed the font property for each label and button control, allowing the system to set the default value. Still no change. Interestingly, if I open the form in design mode, then save it, then close it, then open it again, the buttons have moved… If I do this a few times, the buttons migrate until they're off the form.

Best Answer

OK, I've found the answer, after a bit more fiddling. It seems to be related to the Anchor property on the controls. I made a bunch of changes, testing between each change to see if there was any difference. When I selected all the controls and set the Anchor property to Top, Left, this solved the issue.

I hope this helps someone else at some point!

Related Topic