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

Dynamic Font change for buttons

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

"Jim" <an*******@discussions.microsoft.com> wrote in message
news:11****************************@phx.gbl...
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

Nov 21 '05 #2

P: n/a
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 anyproperties, just create a new font from the existing one with the changedproperty(ies) and assign it to Button.font.

hope that helps..
Imran.

"Jim" <an*******@discussions.microsoft.com> wrote in messagenews:11****************************@phx.gbl...
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

.

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.