VB.Net - Font Dialog Box

Dialog boxes consist of a title bar , an optional main instruction , various controls in the content area , and commit buttons . The Font dialog box lets the user choose attributes for a logical font, such as font family and associated font style, point size, effects , and a script.

vb.net-font-dialog-box.jpg

The following VB.Net program invites a Font Dialog Box and retrieve the selected Font Name and Font Size.

Public Class Form1
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim dlg As New FontDialog
    dlg.ShowDialog()

    If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
      Dim fontName As String
      Dim fontSize As Integer
      fontName = dlg.Font.Name
      fontSize = dlg.Font.Size

      MsgBox(fontName & "  " & fontSize)
    End If

  End Sub
End Class
Next Post Previous Post
No Comment
Add Comment
comment url