This is a migrated thread and some comments may be shown as answers.

Control Scaling on Forms

3 Answers 471 Views
Form
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Iron
Robert asked on 23 Mar 2016, 05:00 PM

Hello,

I can't seem to get various controls (button, label, dropdown, etc.) to scale correctly when the form font size is changed. Actually the size of the control appears to be scaled correctly but the font size of the control remains the same.

For example, create a new application and drop a radbutton on the form. In the form constructor add a change to the form font size:

Public Sub New()

        ' This call is required by the designer.

         InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Dim sysFont As Font = SystemFonts.MessageBoxFont
        Me.Font = New Font(sysFont.Name, 14, sysFont.Style)
    End Sub

At run-time the size of the button increases (good) but the font size remains at the default 8.25. This is not how the MS controls behave when added to the same form. The MS button size and font size change accordingly.

The form AutoScaleMode is set to Font. 

Visual Studio 2015

Windows 10

 

Am I missing something?

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 24 Mar 2016, 09:26 AM
Hi Robert,

Thank you for writing.

By default, our controls do not inherit the Form's font. In our suite the font is set in the themes, inheriting the form's font will override this setting and you will be unable to set the font explicitly in the theme. In this case, you can recursively iterate the controls in the form and set their font.

I hope this information is useful.

Regards,
Dimitar
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Robert
Top achievements
Rank 1
Iron
answered on 24 Mar 2016, 03:58 PM

Thanks Dimitar. I thought it might be something like that. So, if I understand this correctly, for our apps to be fully DPI aware (as set in the app manifest) we will have to iterator through all the Rad controls on all our forms and set the font size appropriately. However, the size of the controls on the form should scale correctly without any coding assist. 

 

 

0
Dimitar
Telerik team
answered on 25 Mar 2016, 07:57 AM
Hi Robert,

Thank you for writing back.

If the controls are auto-sized (by default the labels and textboxes size depends on the font) you would not need any additional code to handle the different DPI settings. However when there are complex controls on the form you should create the layout in such way that the controls are resized according to the available size (using layout panels for example). Detailed information about how you can handle the DPI scaling is available in the following article: WinForms Scaling at Large DPI Settings–Is It Even Possible?

Let me know if you have additional questions.

Regards,
Dimitar
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Form
Asked by
Robert
Top achievements
Rank 1
Iron
Answers by
Dimitar
Telerik team
Robert
Top achievements
Rank 1
Iron
Share this question
or