468,792 Members | 1,724 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,792 developers. It's quick & easy.

Changing a Control's Font Size during runtime

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
1 31911
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.

Similar topics

23 posts views Thread by BobK | last post: by
reply views Thread by Eitan | last post: by
40 posts views Thread by Paul Davis | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.