UserControl AutoScaleMode problem

UserControl AutoScaleMode problem

Old forum URL: forums.lhotka.net/forums/t/7401.aspx


Michael posted on Wednesday, August 05, 2009

Hi everyone

Does anyone know how to get a UserControl to scale properly?

To replicate the problem, you can try the following:

1. Create a test app with a FormBase with
AutoScaleMode = Font, and also a UserControlBase.
2. Before InitializeComponent() in the constructors for FormBase and UserControlBase, set Font = SystemFonts.MessageBoxFont.
3. Create a Form1 inheriting from FormBase with some controls at the top of the form (some labels, text boxes, buttons and a tab control). Remove any reference to AutoScaleMode from Form1's designer file.
4. Create a UserControl1 inheriting from UserControlBase which has the same set of controls that are at the top of Form1. Likewise, remove any reference to AutoScaleMode from UserControl1.Designer.cs.
5. Add an instance of UserControl1 to the bottom of Form1.

The controls at the top Form1 scale correctly. Setting UserControlBase.AutoScaleMode = Font does not work at all - none of UserControl1's controls scale.
Setting UserControlBase.AutoScaleMode = Inherit partially works - the control spacing and button size increases, but the font size for labels, text boxes and buttons do not increase.

I know a lot of us CSLA devs use user controls extensively, so I'd appreciate any insights.

Regards
Michael

Copyright (c) Marimer LLC