Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I set the style (e.g., italics) of a font of a control, since they are read-only properties?

When I try to set a particular font style, say italics, I get an error message "Property cannot be assigned to -- it is read only".

Code such as the following will not work.

control.Font.Italic = true; 

Instead create a new Font object and set the value in its constructor like this:

control.Font = new Font( control.Font, FontStyle.Italic ); 

Contributed from George Shepherd's Windows Forms FAQ



Page view counter