Using Multiple fonts in a Control

Posted on 2006-05-31
Medium Priority
Last Modified: 2013-12-03
I am using C# and I want to be able to use multiple fonts, font sizes in a control.  Specifically I want to be able to display a bar code font, and then a regular fotn right below it in a text box or a rich text box.  I then want to be able to print this data.  I'm not sure how to display multiple fonts in the control.
Question by:rshooper76
LVL 96

Accepted Solution

Bob Learned earned 2000 total points
ID: 16798989
With a RichTextBox, here is an example:

Font h1 = new Font("Tahoma", 14, FontStyle.Bold);
Font h2 = new Font("Tahoma", 10);

rtf.SelectionFont = h1;
rtf.AppendText("Heading 1");
rtf.SelectionFont = h2;
rtf.AppendText("Heading 2");



Expert Comment

ID: 16799148
Hi rshooper76,

I had to do more or less the same thing for a postal application I was working on. The application needed to display an address, and at the top display the barcode equivalent of some number in the address.

What I ended up doing was using a label or (border-less TextBox) for writing the string in barcode font there, and then I put (in my case) a multiline textbox (also borderless) right underneath for the address. For all purposes, it looked like they were in the same control.

The only problem I had was with the barcode font. Several of the clients didn't have the barcode font installed so I had to manually install it during the program installation.  The weird thing was that File.Copy doesn't work: you either have to copy the file into the Windows Font folder  with Windows Explorer (it automatically runs an installation process)or use the the classes provided by .Net for these things.

Hope this helps,

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

840 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