Changing a Control's Font Size during runtime


G

Guest

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.
 
Ad

Advertisements

V

Vijaye Raji

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);
 
P

Parrot

Thanks for your reply. Can I change the font associated with an image
control on a web page? That is where I need to control the font size as I
wish to use an image map as a template for plotting numbers, etc. However,
if the font size of the browser is set to a larger size than I expect, the
template will not be plotted correctly. Thus, can I change the text on a
System.Web.UI.WebControls.Image control. I did not see any properties for
font on the control.
 
Ad

Advertisements

C

Cor Ligthert[MVP]

Parrot,

I think you are now facing the limitations of HTML even dynamic HTML.

I am not aware of it, but in your case I would have a look what Silverlight
maybe can do already for me.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top