JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Setting Button Fonts

You've written an adventure-type game for your grandfather, but he's emailed to let you know he can't read the "tiny text" in the buttons; he likes to run his screen in super high resolution mode. Can you fix that?

Yes you can—all you have to do is to make the font size in the buttons' captions larger. To do that, you use the button's Font property. Selecting the Font item in the property window and then clicking the ellipsis ("") button that appears opens the Font dialog shown in Figure 6.7. As that figure shows, you can see all kinds of fonts and settings for buttons' captions, and the Microsoft Sans Serif font goes up to 72 points, which should be big enough for grandfather.

Click To expand
Figure 6.7: Selecting a font for a button.

You also can set the Font property of a button at run time. Here's an example, where I'm changing a button's caption to italic to give it a little more emphasis. First, I recover the current Font object in the button, then I use the Font class's constructor to base a new font on that original font, but making the new font italic:

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    Button1.Font = New Font(Button1.Font, FontStyle.Italic)
End Sub
Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor