Changing font of label at runtime

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
LVL 14
Farzad AkbarnejadDeveloperAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Fahad MukhtarConnect With a Mentor Distinguished EngineerCommented:
label1.Font = new Font(label1.Font.FontFamily ,label1.Font.Size  ,FontStyle.Bold);
0
 
jjacksnCommented:
you have to set the actual font property

label1.Font = new Font(....)
0
 
123654789987Commented:
label1.Font.Bold is a readonly property

                                               Label label1 = new Label();
                  Font font1 = new Font(FontFamily.GenericMonospace,14,FontStyle.Bold);
                  label1.Font = font1;
0
 
shilpa2784Commented:
label1.Font = new System.Drawing.Font(label1.Font,FontStyle.Bold);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.