Using VS Designer results in controls being moved around or resized.

0
0

Hello Wisej.

This is a problem that I have noticed for a long time but haven’t found a solution for it in the forum. With Wisej forms that have a number of controls (buttons, textboxes and datagridviews etc.) I find that after I edit the form in the Visual Studio designer some controls will be resized and some will have their location changed. This most often happens with datagridviews, they end up much wider than when the form was opened, but other controls (buttons, labels etc.) can also b affected, they often go from having a Location value of something like (100, 100) to a value of something like (1000, 2000) and are off the screen when the application is run. Even making a small change to a complicated screen can result in having to spend half an hour putting controls back to their original locations. Simpler screens, with only a few buttons and a few textboxes never seem to have this happen to them.

Any ideas what is causing this or what I can do to avoid this happening ?

I am using Wisej version 3.5.11 (and Visual Studio 2022) but this problem has been happening for the past 5 years so is not limited to this version.

Thanks

Andrew

  • You must to post comments
0
0

It’s more a Visual Studio designer issue than a wisej issue. Here are some things that might help:

1.Turn off automatic scaling
In your form constructor, set:

this.AutoScaleMode = Wisej.Web.AutoScaleMode.None;

This prevents the designer from “helpfully” resizing controls when DPI or font scaling changes.

2.Be careful with Dock + Anchor mix
Stick to one layout mechanism per container:

If you Dock a DataGridView, don’t also Anchor it.

If you use TableLayoutPanel, let it fully control sizing.

3.Lock controls in the designer
In VS Designer, right-click → Lock Controls. This stops random repositioning.

4.Avoid autosizing containers

AutoSize = true on panels and group boxes often forces recalculation.

Turn it off unless you really need it.

5.Watch inherited forms / user controls
If your form inherits from a base form with a different DPI or scaling, VS sometimes shifts controls. Setting AutoScaleMode.None on both base and derived forms helps.

Hope this helps!

-Julie

  • Andrew Pearce
    Thank you for your reply Julie. I have made the changes that you suggested in your answer. Over the next few days I will be using the form that has been the worst offender for resizing and moving controls and I will watch what happens. I will let you know how it goes.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.