Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

How to set the FontDialog-component to a certain fontname/size by pressing on a button.

Hi Experts,

I am programming in VS2010 and I am using C#.
On my dialog-form I have a Button, editbox(readonly) and
a FontDialog-component.

A user can press the button and the FontDialog-window
appears the user can then set his fontname, size etc...
After closting the fontdialog-window, the choosen Font-
Name and size appears in the editbox.

        private void btnFontType_Click(object sender, EventArgs e)
        {
            if (fontDialog1.ShowDialog() == DialogResult.OK)
            {
                txtFont.Text = Convert.ToInt32(this.fontDialog1.Font.SizeInPoints).ToString() + " pt. " +
                fontDialog1.Font.Name;
            }
        }

Open in new window


What I would like is to create a button called Default, that sets the fontdialog to
the default fontname: Microsoft Sans Serif and default fontsize: 8.

How can I do that?

Greetings,

Peter Kiers
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Kiers

ASKER

Thanks. Peter