For user control AutoScaleMode applies to the contents
of the container – that way controls within a form can be repositioned and
scaled according the Form level AutoScaleMode and the user control contents are
scaled according to the user control level AutoScaleMode. Below is the same
form with user control with three different combinations of user control
AutoScaleMode and FixedWidth/FixedHeight.
|
Comment |
Starting form (Font 8) |
Starting Form (Font 12) |
|
Default
UserControl
location scaled
size scaled
UserControl Contents
location scaled
size scaled
|
![]() |
![]() |
|
UserControl.AutoSizeMode = None;
UserControl
location scaled
size scaled
UserControl Contents
Location NOT scaled
size NOT scaled
|
![]() |
![]() |
|
UserControl.AutoSizeMode = None;
UserControl.ControlStyles FixedWidth/Height true
UserControl
location scaled
size NOT scaled
UserControl Contents
location NOT scaled
size NOT scaled
|
![]() |
![]() |
NOTE: The code used to enable fixed width fixed height user
control:
public UserControl1()
{
this.SetStyle(ControlStyles.FixedHeight | ControlStyles.FixedWidth, false);
}