|
|
Title | Change a form's font in Visual Basic .NET |
Description | This example shows how to change a form's font in Visual Basic .NET. |
Keywords | font, change font, VB.NET |
Categories | VB.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.
|
|
|
|
|
|