Thursday, September 13, 2007

Beware of the AutoScaleBaseSize property

I have had a problem recently with some of the form in my application, which were descendants of a custom form class (not the classic Windows.Forms.Form class).
The form would look fine in design mode, but during run time it appeared to have shrunk, with all the controls in it being affected similarly.

It took a lot of digging to find out what was wrong, but after noticing that setting the AutoScale property to "false" seemed to solve the problem the culprit was found - While in a "normal" form the "initializecomponents" method contained this line:
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
In the new forms it has somehow changed to:
this.AutoScaleBaseSize = new System.Drawing.Size(7, 17);
Thus affecting all such forms.

Now I need to fix this line, but I'm still troubled by not knowing what caused it to change in the first place....

No comments: