Solved

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

Posted on 2011-09-02
5
389 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 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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

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…
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
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

624 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