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.net | Description |
|---|---|---|
| 1. | AllowSimulations | Gets or sets a value indicating whether the dialog box allows graphics device interface (GDI) font simulations. |
| 2. | AllowVectorFonts | Gets or sets a value indicating whether the dialog box allows vector font selections. |
| 3. | AllowVerticalFonts | Gets or sets a value indicating whether the dialog box displays both vertical and horizontal fonts, or only horizontal fonts. |
| 4. | Color | Gets or sets the selected font color. |
| 5. | FixedPitchOnly | Gets or sets a value indicating whether the dialog box allows only the selection of fixed-pitch fonts. |
| 6. | Font | Gets or sets the selected font. |
| 7. | FontMustExist | Gets 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. | MaxSize | Gets or sets the maximum point size a user can select. |
| 9. | MinSize | Gets or sets the minimum point size a user can select. |
| 10. | ScriptsOnly | Gets 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. | ShowApply | Gets or sets a value indicating whether the dialog box contains an Applybutton. |
| 12. | ShowColor | Gets or sets a value indicating whether the dialog box displays the color choice. |
| 13. | ShowEffects | Gets or sets a value indicating whether the dialog box contains controls that allow the user to specify strikethrough, underline, and text color options. |
| 14. | ShowHelp | Gets or sets a value indicating whether the dialog box displays a Help button. |
Font Dialog Methods in VB.net
The Font Dialog Box in VB.net has the following Methods:
| # | Font Dialog Methods in VB.net | Description |
|---|---|---|
| 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. |
Font Dialog Events in VB.net
The Font Dialog Box in VB.net has the following Events:
| # | Font Dialog Events in VB.net | Description |
|---|---|---|
| 1. | Disposed | When control or component is terminated by calling the Dispose() method, a Dispose event occurs. |
| 2. | HelpRequest | When a user clicks the Help button of the dialog box, the HelpRequest event is called. |
| 3. | Apply | When a user clicks on the Apply button of the Font dialog box, an apply event occurs. |
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 ClassProgram Output:
Here’s the Output, based on the given program above.
Write some text in the TextArea box, as shown below.
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.
After you set the font, font style, size, color, etc. on the Font dialog box, it shows the formatted string, as shown below.
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.
PREVIOUS
NEXT
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().






