Control Scaling on Forms

4 posts, 0 answers
  1. Robert
    Robert avatar
    4 posts
    Member since:
    Dec 2015

    Posted 23 Mar Link to this post

    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?

  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 24 Mar Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Robert
    Robert avatar
    4 posts
    Member since:
    Dec 2015

    Posted 24 Mar in reply to Dimitar Link to this post

    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. 

     

     

  5. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 25 Mar Link to this post

    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.
Back to Top