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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With