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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

895 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

13 Experts available now in Live!

Get 1:1 Help Now