Jan 17, 2008

I get an error message "Property cannot be assigned to -- it is read only". How can I set this read only property?

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". How can I set this read only property?


Code such as

tabControl1.Font.Italic = true;

will not work. Instead, you have to create a new Font object, and set the property during its creation. This code will work.

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