Solved

Display the chosen fontname en fontsize of a fontdialog in a textbox, part2

Posted on 2011-09-02
5
379 Views
Last Modified: 2013-12-17
Hi,

I have a button, a textbox and a fontdialog on my form.
When I click on the button the fontdialog appears
Where I can choose the fontname and size

What would is in the textbox, the size of the font
and the name of the font that I have chosen
in the fontdialog. How can I do that?

I have put an image of outlook so you see how I
want it to be.

Who knows the answer and is willing to help me?

Greetings, Peter Kiers
Example1.jpg
0
Comment
Question by:peterkiers
  • 3
  • 2
5 Comments
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 36472616
Try this:

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

Open in new window


Hope that helps.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36472664
I am going to try your code now

Peter
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36472725
It works. But when I choose Comic Sans MS and size 10 I get:

9,75 pt. Comic Sans MS

How come I get 9,75 and not 10.

Peter
0
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 500 total points
ID: 36472745
Try this:

this.textBox1.Text = Convert.ToInt32(this.fontDialog1.Font.SizeInPoints).ToString() + " pt. " + this.fontDialog1.Font.Name;
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36472775
Great. 500 points are comming to you...

Greetings, Peter Kiers
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

18 Experts available now in Live!

Get 1:1 Help Now