Dynamic Font change for buttons

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

Working with VB.net under VS.Net 2003.

Have a simple form with a Button1. I want to change the
font on the button when the button is clicked.

Is there a way to Dynamically change the Font for Button1
from regular to bold, change the size etc. This line of
code:
Button1.Font.Bold = True

gives an error:
property is read only.

I know it can be changed in the designer, but the users
would like some further emphasis in the button label if
the button has been clicked.

What am I missing?

Thanks
 
Button1.Font = New Font(Button1.Font, FontStyle.Bold)

Button1.Font = New Font(Button1.Font, FontStyle.Bold Or FontStyle.Italic)

The properties of Button.Font are read-only. So if you need to change any
properties, just create a new font from the existing one with the changed
property(ies) and assign it to Button.font.

hope that helps..
Imran.
 
Thanks - that works.
-----Original Message-----
Button1.Font = New Font(Button1.Font, FontStyle.Bold)

Button1.Font = New Font(Button1.Font, FontStyle.Bold Or FontStyle.Italic)

The properties of Button.Font are read-only. So if you need to change any
properties, just create a new font from the existing one with the changed
property(ies) and assign it to Button.font.

hope that helps..
Imran.




.
 

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

Back
Top