1

I'm having a variety of weird issues with the WinForms Designer and wondering if anyone knows of a fix. I'll just lay out some of the symptoms here (in case they're all symptoms of the same problem).

I have an issue where my tabpage controls are getting "compressed" into the top left corner when I close and re-open the designer for the form.

![screenshot](https://i.imgur.com/3gWPYJE.png)

The controls that seem to be affected are anchored to the Bottom (sometimes Bottom-Left, sometimes Bottom-Right but always includes "Bottom"). If I move the controls to where they're supposed to be, save, close the designer, then reopen it - they're all "compressed" back in the top left corner.

Even weirder is that the properties shown in the properties pane for some of the controls (the checkbox for instance) does not match what is in the Form.Designer.cs file (Form.Designer.cs has the correct location values):

![screenshot](https://i.imgur.com/lUavNUA.png)

When running my application, it shows the "compressed" controls and doesn't reflect the values in the Form.Designer.cs file (which are correct).

Finally, sometimes when I go to save the file, Visual Studio pops up a "Save As" dialog box as if it didn't know where the file was actually located, but then prompts me to overwrite the exact same file (even if there were no changes).

screenshot

If anyone has any ideas of what could be causing these things, that'd be very helpful! I have tried investigating the "Document Outline" window to see if there is some odd parenting going on (there wasn't), tried tweaking the Form.Designer.cs file to fix it (it didn't so I undid those changes), and a couple other things.

9
  • 1
    Did you try to recreate a new form then copy/paste your old controls and code while reassigning events? Commented Oct 10, 2019 at 14:31
  • 1
    @OlivierRogier haven't tried that yet - I can give that a shot Commented Oct 10, 2019 at 14:35
  • The CheckBox control has the Anchor set to Left-Bottom, so it will change the "Location" of the control based on the size of the container. Commented Oct 10, 2019 at 23:16
  • You might be able to avoid problem by designing the user control at the same size as the available space in its container. Also, does your user control has custom code related to resizing? Commented Oct 11, 2019 at 1:33
  • 1
    Your question seems to concentrate on the controls inside the UserControl, but the problem is with the UserControl itself. I would update the question with that information. Move the "Save As" issue into a new question. Stack Overflow prefers one topic questions. Commented Oct 11, 2019 at 13:40

1 Answer 1

-1

Well, I didn't ever find out the real reason this was happening, but I found the cause (and a workaround solution).

The cause is my usercontrol on the "Editor" tab page (everything inside that red rectangle is part of one usercontrol):

enter image description here

I am not sure why this would cause all the "rearranging" issues - until recently I had all these controls on the tab page themselves (without the usercontrol "parent"). But maybe the Designer is getting overloaded somehow and is placing controls in weird locations.

Whatever the cause is, the "fix" (if you could call it that) was to remove the usercontrol from the designer and add it to the form at startup. I do all the designing of the usercontrol in its own designer any way so this should be sufficient for now.

If anyone has any ideas as to what could truly have been causing this, let me know.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.