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