By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,787 Members | 2,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,787 IT Pros & Developers. It's quick & easy.

Changing a Control's Font Size during runtime

P: n/a
It it possible to change a button's or text box's font size during runtime?

When I try to build my application with this code:
this.ActiveControl.Font.Size = "8.25";
I get this error message:
Property or indexer "System.Drawing.Font.Size' cannot be assigned to -- it
is read only

I can change a button's text property during runtime, but I'd also like to
change the font size as well.
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Font is immutable. You cannot change its value. However, you can set the
Font property on the control you're working with, say,

this.ActiveControl.Font = new Font(this.ActiveControl.Font.FontFamily, 8.25,
this.ActiveControl.Font.Style);

-vJ

new Font(this.Font.FontFamily, 12, this.Font.Style);
"Jeff N" <Jeff N@discussions.microsoft.com> wrote in message
news:33**********************************@microsof t.com...
It it possible to change a button's or text box's font size during
runtime?

When I try to build my application with this code:
this.ActiveControl.Font.Size = "8.25";
I get this error message:
Property or indexer "System.Drawing.Font.Size' cannot be assigned to -- it
is read only

I can change a button's text property during runtime, but I'd also like to
change the font size as well.

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.