Link to home
Start Free TrialLog in
Avatar of Farzad Akbarnejad
Farzad AkbarnejadFlag for Iran, Islamic Republic of

asked on

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
Avatar of jjacksn
jjacksn

you have to set the actual font property

label1.Font = new Font(....)
ASKER CERTIFIED SOLUTION
Avatar of Fahad Mukhtar
Fahad Mukhtar
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
label1.Font.Bold is a readonly property

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