Solved

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

Posted on 2012-03-13
2
357 Views
Last Modified: 2012-03-13
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
0
Comment
Question by:peterkiers
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
Comment Utility
FontDialog1.Font = New Font("Microsoft Sans Serif", 8)
            FontDialog1.ShowDialog()
0
 
LVL 1

Author Comment

by:peterkiers
Comment Utility
Thanks. Peter
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now