Font Dialog Box in VB.net – Properties, Methods and Events

What is Font Dialog in VB.net?

A Font Dialog in VB.net is used to choose a font from a system’s installed fonts.

Please keep in mind that a FontDialog may have different fonts on different systems depending on what fonts are installed on a system.

Font Dialog Properties in VB.net

The Font Dialog Box in VB.net has the following Properties:

#Font Dialog Properties in VB.netDescription
1.AllowSimulationsGets or sets a value indicating whether the dialog box allows graphics device interface (GDI) font simulations.
2.AllowVectorFontsGets or sets a value indicating whether the dialog box allows vector font selections.
3.AllowVerticalFontsGets or sets a value indicating whether the dialog box displays both vertical and horizontal fonts, or only horizontal fonts.
4.ColorGets or sets the selected font color.
5.FixedPitchOnlyGets or sets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts.
6.FontGets or sets the selected font.
7.FontMustExistGets or sets a value indicating whether the dialog box specifies an error condition if the user attempts to select a font or style that does not exist.
8.MaxSizeGets or sets the maximum point size a user can select.
9.MinSizeGets or sets the minimum point size a user can select.
10.ScriptsOnlyGets or sets a value indicating whether the dialog box allows selection of fonts for all non-OEM and Symbol character sets, as well as the ANSI character set.
11.ShowApplyGets or sets a value indicating whether the dialog box contains an Applybutton.
12.ShowColorGets or sets a value indicating whether the dialog box displays the color choice.
13.ShowEffectsGets or sets a value indicating whether the dialog box contains controls that allow the user to specify strikethrough, underline, and text color options.
14.ShowHelpGets or sets a value indicating whether the dialog box displays a Help button.
Properties and Descriptions of Font Dialog Box in VB.net

Font Dialog Methods in VB.net

The Font Dialog Box in VB.net has the following Methods:

#Font Dialog Methods in VB.netDescription
1.Equals()The Equals() method is used to check whether the current or defined object is the same.
2.OnHelpRequest()It is used to call the HelpRequest event in the dialog box.
3.Reset()The Reset() method is used to reset all changes to their default values.
4.Dispose()The Dispose() method is used to free all resources used by the Control or the component in the Dialog Box.
5.RunDialog()It is used to override a derived class to create a common dialog box.
6.ShowDialog()The ShowDialog () method is used to run a common dialog box with the default setting.
7.CreateObjRef()The CreateObjRef () method is used to create an object that contains all related information to initialize a proxy that can communicate with a remote object.
Methods and Description of Font Dialog Box in VB.net

Font Dialog Events in VB.net

The Font Dialog Box in VB.net has the following Events:

#Font Dialog Events in VB.netDescription
1.DisposedWhen control or component is terminated by calling the Dispose() method, a Dispose event occurs.
2.HelpRequestWhen a user clicks the Help button of the dialog box, the HelpRequest event is called.
3.ApplyWhen a user clicks on the Apply button of the Font dialog box, an apply event occurs.
Events and Descriptions of Font Dialog Box in VB.net

Let’s make a simple program that uses VB.NET Windows Forms to show the Font dialog box.

Public Class Form1
FontDialog1.ShowColor = True  
        If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then  
            TextBox1.Font = FontDialog1.Font 'Change the font of the selected string  
            TextBox1.ForeColor = FontDialog1.Color 'Change the color of selected string  
        End If  
End Class

Program Output:

Here’s the Output, based on the given program above.

Font Dialog Box in VB.net Output
Font Dialog Box in VB.net Output

Write some text in the TextArea box, as shown below.

Font Dialog Box in VB.net Insert Text
Font Dialog Box in VB.net Insert Text

By choosing the string and clicking the “Change Font” button, the Font window will open. In the Font window, we can change the selected string’s size, font, and font style.

Font Dialog Box in VB.net Change Font
Font Dialog Box in VB.net Change Font

After you set the font, font style, size, color, etc. on the Font dialog box, it shows the formatted string, as shown below.

Font Dialog Box in VB.net Display Results
Font Dialog Box in VB.net Display Results

Summary

A FontDialog Control in VB.net lets the user open the Windows Font Dialog and choose a font and color for the font.

In this article, we talked about how to use a Windows Font Dialog in a Windows Forms application using Microsoft Visual Studio and set its properties.


Common use cases for Font Dialog Box

Font Dialog Box appears in most Windows Forms applications. Typical scenarios:

  • File save operations. Prompt users to pick a target file name and format before writing data.
  • File open operations. Let users browse for spreadsheets, images, PDFs, or configuration files to import.
  • Font selection. Give users control over typography in rich-text editors, report designers, or accessibility settings.
  • Color selection. Used in drawing apps, chart configurators, and theme editors.
  • Print previews. Route content to the printer with pagination and margins under user control.

Best practices when using Font Dialog Box

  • Always set a default. Users expect a sensible starting value (e.g., the last used color or the current font).
  • Handle DialogResult. Check whether the user clicked OK vs Cancel before applying changes.
  • Set filters correctly. For file dialogs, restrict extensions to the ones your app actually reads.
  • Wrap in Using blocks. Dialog objects hold OS resources; Using ensures cleanup.
  • Test on high-DPI monitors. Dialogs render differently at 125% and 150% scaling.

Working code example

Full working example showing Font Dialog Box in a real Windows Forms context:

Private Sub btnPick_Click(sender As Object, e As EventArgs) Handles btnPick.Click
    Using dlg As New OpenFileDialog()
        dlg.Title = "Select a file"
        dlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
        dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)

        If dlg.ShowDialog() = DialogResult.OK Then
            Dim contents As String = System.IO.File.ReadAllText(dlg.FileName)
            txtOutput.Text = contents
        End If
    End Using
End Sub

Troubleshooting common issues with Font Dialog Box

  • Dialog does not appear. Confirm ShowDialog() is called on the UI thread. Cross-thread invocations must marshal via Control.Invoke().
  • File permission errors. Wrap file operations in Try/Catch. UAC-protected folders throw UnauthorizedAccessException.
  • Filter string ignored. Filters use the exact “Description|*.ext|Description2|*.ext2” format. A single stray character breaks parsing silently.
  • Font not applied. After dialog closes, assign dlg.Font to the target control’s Font property explicitly.
  • Print job silently drops. Confirm PrinterSettings.IsValid before calling Print().

Frequently Asked Questions

What is the Font Dialog Box in VB.NET?
The Font Dialog Box in VB.NET is a modal Windows Forms dialog that lets users pick a value (file, font, color, or printer setting) without writing custom UI code. It ships with the .NET Framework in the System.Windows.Forms namespace.
How do I show the Font Dialog Box in code?
Create an instance, set its default properties, and call ShowDialog(). Wrap it in a Using block so system resources are released even if the user closes the dialog with the X button.
How do I know if the user clicked OK on the Font Dialog Box?
ShowDialog() returns a DialogResult enumeration. Compare against DialogResult.OK before reading the dialog’s property values, otherwise you may end up processing an unpicked or default value.
Why does the Font Dialog Box appear behind my form?
Pass Me (the current form) as the owner argument: dlg.ShowDialog(Me). Without an owner, the dialog can appear behind other windows or be misplaced across multi-monitor setups.
Can I customize the Font Dialog Box appearance?
The built-in dialogs are OS-provided and only offer limited customization through their properties. For deeper styling you must write a custom form that mimics the dialog behavior.
Angel Jude Suarez


Full-Stack Developer at PIES IT Solution

Focuses on Python development, machine learning, and AI integration. Has built production AI systems including OpenAI Whisper integration for medical transcription and GPT-4o-powered diagnosis assistance. Strong background in pandas, scikit-learn, and TensorFlow.

Expertise: Python · PHP · Java · VB.NET · ASP.NET · Machine Learning · AI Integration · OpenCV · Django · CodeIgniter
 · View all posts by Angel Jude Suarez →

Leave a Comment