Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-02
5
Medium Priority
?
391 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

704 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