Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop Visual Studio from resizing my controls?

Visual Studio 2008 SP1 (although IIRC, the behavior was present in 2005 as well) keeps resizing a couple of grid controls (Janus.GridEx to be precise) I use.

I can resize them back to normal, save, and compile just fine. When it does compile, these two controls will expand to ridiculous values.

More Information: This problem is related to setting the Anchor property on the control. If I set the Anchor property to opposing ends (say Left and Right), when the Designer file gets compiled, it sets the width/height of the control to the width/height of the container.

It seems that in the Designer file, the Anchor property is set before the Size property. Manually editing (I know, shame on me) the file to put the Size property first doesn't help as when the Designer file gets compiled, it seems to be rewritten from scratch as well.

So I guess my real question is how to make VS form designer respect my initial size declaration as well as the Anchor property.

like image 375
Benjamin Autin Avatar asked Oct 10 '08 20:10

Benjamin Autin


3 Answers

I had the same problem. The instances of my user control on the form had these settings. anchor - none autosize - false dock - none

It still horribly resized them every time I did a build etc.

I found that on the user control in the design properties it had autoscalemode set to font. I change it to none and that fixed the problem.

like image 119
Rich Avatar answered Oct 04 '22 01:10

Rich


I usually solve that kind of trouble by putting the 'good' code in the form constructor, right after the call to InitializeComponent(), so it overrides any mess the automatic designer magic might cause.

like image 24
user26918 Avatar answered Oct 03 '22 23:10

user26918


What I'm doing currently is handling the Resize event and setting the Size on the two required controls. I feel this is a bit of a kludge given the intended effect of the Anchor property.

like image 44
Benjamin Autin Avatar answered Oct 03 '22 23:10

Benjamin Autin