Changing font of label at runtime

Posted on 2004-09-09
Last Modified: 2013-12-03
I have a label on a form. When I want to change the font of it at run time, it gives me an error that "The property is read-only".

label1.Font.Bold = true;

How can I change the font of label or textbox at runtime?

Question by:Farzad Akbarnejad
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

Expert Comment

ID: 12023798
you have to set the actual font property

label1.Font = new Font(....)
LVL 19

Accepted Solution

Desp earned 250 total points
ID: 12023800
label1.Font = new Font(label1.Font.FontFamily ,label1.Font.Size  ,FontStyle.Bold);
LVL 10

Expert Comment

ID: 12023834
label1.Font.Bold is a readonly property

                                               Label label1 = new Label();
                  Font font1 = new Font(FontFamily.GenericMonospace,14,FontStyle.Bold);
                  label1.Font = font1;

Expert Comment

ID: 12023917
label1.Font = new System.Drawing.Font(label1.Font,FontStyle.Bold);

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

636 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