• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1549
  • Last Modified:

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
0
Farzad Akbarnejad
Asked:
Farzad Akbarnejad
1 Solution
 
jjacksnCommented:
you have to set the actual font property

label1.Font = new Font(....)
0
 
Fahad MukhtarDistinguished EngineerCommented:
label1.Font = new Font(label1.Font.FontFamily ,label1.Font.Size  ,FontStyle.Bold);
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now