Javatpoint Logo
Javatpoint Logo

VB.NET Font Dialog Box

The Font Dialog Box allows the user to select the font family, style, and size for the text in an application. However, a user can also select the font color and apply the current setting to the selected text of the control by clicking the Apply button.

Let's create a Font Dialog box in the VB.NET Windows form using the following steps.

Step 1. We need to drag the Font Dialog box from the toolbox and drop it to the Windows form, as shown below.

VB.NET Font Dialog Box

Step2: Once the Font Dialog is added to the form, we can set various properties of the Font by clicking on the Font Dialog box.

Properties of Font Dialog

There are following properties of the Font Dialog Box in the VB.NET.

Properties Description
ShowApply The ShowApply property sets a value representing whether you want to display the Apply button on the dialog box.
ShowEffects The ShowEffects property is used to set various effects on the text such as strikethrough, text color, and underline options by setting values on the FontDialog box.
Font The Font property is used to get or set the selected font to display changes.
Container The Container property is used to get the IContainer that contains the Component of the Font Dialog Box.
AllowVerticalFonts The AllowverticalFonts property is used to set or get a value that represents whether the Font dialog box displays the horizontal and vertical fonts or displays only horizontals fonts.
AllowScriptChange The AllowScriptChange property is used to set a value that allows the user to change the character specified in the Script combo box to show a character set other than the currently displayed character.
ScriptOnly The ScriptOnly property is used to set a value that allows the user to select only the font, the character set of the symbol, and the ANSI character from the dialog box.
ShowHelp The ShowHelp property is used to set a value representing whether the Help button should be displayed in the dialog box.
MaxSize The MaxSize property gets or sets a value that allows the user to select only the maximum point size character.
Options It is used to initialize FontDialog by obtaining values.

Methods of Font Dialog

Method Description
Equals() The Equals() method is used to check whether the current or defined object is the same.
OnHelpRequest() It is used to call the HelpRequest event in the dialog box.
Reset() The Reset() method is used to reset all changes to their default values.
Dispose() The Dispose() method is used to free all resources used by the Control or the component in the Dialog Box.
RunDialog() It is used to override a derived class to create a common dialog box.
ShowDialog() The ShowDialog () method is used to run a common dialog box with the default setting.
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.

Events of Font Dialog

Events Description
Disposed When control or component is terminated by calling the Dispose() method, a Dispose event occurs.
HelpRequest When a user clicks the Help button of the dialog box, the HelpRequest event is called.
Apply When a user clicks on the Apply button of the Font dialog box, an apply event occurs.

Let's create a simple program to display the Font dialog box in the VB.NET Windows Forms.



VB.NET Font Dialog Box

Write some text in TextArea, as shown below.

VB.NET Font Dialog Box

Select the string and click the 'Change Font' button; it opens the Font window. In the Font window, we can change the size, font, and font style of the selected string.

VB.NET Font Dialog Box

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

VB.NET Font Dialog Box

Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA