Ticket Q485788
Visible to All Users

How to change font size for all controls in an application including a NavBar, Ribbon, Layout and XtraEdit Controls?

created 12 years ago

I'm trying to introduce a button on my ribbon bar of my main form in a WinForms application that changes the font size globally (increase font / decrease font). In my application I have a RibbonControl, a NavBarControl, a LayoutControl, and a bunch of XtraEdit controls.
These lines of code seem to do the trick for the RibbonControl and the NavBarControl:

C#
var f = DevExpress.Utils.AppearanceObject.DefaultFont; DevExpress.Utils.AppearanceObject.DefaultFont = new Font(f.FontFamily, f.Size + 1); LookAndFeelHelper.ForceDefaultLookAndFeelChanged();

The XtraEdit Controls do not change in their font size.

And if I change the font size individually for each control using the following code:

C#
public void IncreaseFont() { foreach (Control cntrl in lcLayout.Controls) ChangeFontSize(cntrl, 1); } private void ChangeFontSize(Control cntrl, float value) { if (cntrl.HasChildren) { foreach (Control child in cntrl.Controls) ChangeFontSize(child, value); } else { var f = cntrl.Font; cntrl.Font = new Font(f.FontFamily, f.Size + value); } }

Then they change back to the original font size when this line is called:

C#
LookAndFeelHelper.ForceDefaultLookAndFeelChanged();

What is the best way to globally change font size for all controls? Thanks,
Dave

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hello David,
Please refer to the how to set default font? thread that describes possible ways of setting a font.
Should you have any further questions, feel free to contact us.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.