Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleChange a form's font in Visual Basic .NET
DescriptionThis example shows how to change a form's font in Visual Basic .NET.
Keywordsfont, change font, VB.NET
CategoriesVB.NET, Graphics
 
By default, the controls on a form inherit the form's font. When you check and uncheck this program's Big Font check box, the program changes the form's font and all of the controls on it inherit the change.
 
Private Sub chkSize_CheckedChanged(ByVal sender As _
    System.Object, ByVal e As System.EventArgs) Handles _
    chkSize.CheckedChanged
    If chkSize.Checked Then
        Me.Font = New Font(Me.Font.FontFamily, 13.5, _
            GraphicsUnit.Point)
    Else
        Me.Font = New Font(Me.Font.FontFamily, 8.5, _
            GraphicsUnit.Point)
    End If
End Sub
 
To prevent a control from inheriting changes to its form's font, set its font explicitly. Notes:

  • If you set the font to the same value it currently has (initially the same as the form's font), the control still inherits changes.
  • If you set the font to something else and then set it back, the control will keep the original font even when the form's font changes.
  • To make the control inherit the form's font again, right-click on the control's Font property in the property window and select Reset.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated