Changing the Fonts of WinForm Controls

I have a basic form. When I click Tools-> Options from my application menu, I show another form (OptionsForm) that contains options for changing the font used by the controls. I save the selected font in the properties: Settings: default: some_object. I can get it and update my controls, but only when I click a button on my MainForm.

I tried to call a function written in MainForm from OptionsForm by creating an instance of MainForm to update the control. Font → not working.

How to make sure that whenever I change the font in the properties: Settings: Default: some_object, all controls reflect the change?

Thanks Dev

+3
source share
2
  • "(ApplicationSettings)" , .
  • "..." - "(PropertyBinding)".
  • "" .
  • , "UserFont" "".
  • 1 4 , , , , , "" 3.
  • , , , . :

private void button1_Click(object sender, EventArgs e)
{
    if (DialogResult.OK == fontDialog1.ShowDialog(this))
    {
        button1.Font = fontDialog1.Font;
    }
}

, . .

Edit: ( , ) , :

WindowsFormsApplication1.Properties.Settings.Default.UserFont = fontDialog1.Font;
+2

.

.

1 -

Form2 frm2 = new Form2();
frm2.ShowDialog(this);

Button2

Properties.Settings.Default.MyFont = this.Font;
            Properties.Settings.Default.Save();
            (from Control ctrl in this.Owner.Controls
             select ctrl).ToList().ForEach(ctrl => ctrl.Font = Properties.Settings.Default.MyFont);

.

+2

All Articles