Solved

Changing font of label at runtime

Posted on 2004-09-09
4
1,536 Views
Last Modified: 2013-12-03
Hello,
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?

Thanks
-FA
0
Comment
Question by:Farzad Akbarnejad
4 Comments
 
LVL 5

Expert Comment

by:jjacksn
ID: 12023798
you have to set the actual font property

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

Accepted Solution

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

Expert Comment

by:123654789987
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;
0
 

Expert Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SqlDependency to get update from sql to my c# app 2 63
How to install a font on WIN2003SBS/IIS 6 & test 17 32
Where is this file? 3 25
Please explain purpose of GZIP 4 34
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

839 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