|
|
Title | Create fonts easily by using the Font constructor that uses a prototype in Visual Basic .NET |
Description | This example shows how to create fonts easily by using the Font constructor that uses a prototype in Visual Basic .NET. |
Keywords | Font, create font, font prototype, VB.NET |
Categories | Graphics, VB.NET |
|
|
Thanks to Gary Winey.
The Font class provides a constructor that takes only two parameters: an existing font to use as a prototype and a set of font styles (bold, italic, etc.). This is the easiest way to create a new font.
This example reads some check boxes to see what styles to use. It then uses this version of the Font constructor and sets a Label control's Font property to the result.
|
|
Private Sub btnCreateFonts_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles _
btnCreateFonts.Click
Dim font_style As FontStyle = FontStyle.Regular
If chkBold.Checked Then font_style = font_style Or _
FontStyle.Bold
If chkItalic.Checked Then font_style = font_style Or _
FontStyle.Italic
If chkStrikeout.Checked Then font_style = font_style Or _
FontStyle.Strikeout
If chkUnderline.Checked Then font_style = font_style Or _
FontStyle.Underline
lblSample.Font = New Font(Me.Font, font_style)
End Sub
|
|
|
|
|
|