Creating custom font dialog box in VB.NET
This article shows how to create a font dialog box in VB.NET windows forms application.
In this article we will learn about the font dialog control in window application in VB.NET.
Font dialog control are used to select a color and Font. Font dialog control has some common property which are as following:
Color Property used to get or set the selected font color.
Font Property used to get or set the selected font.
Showcolor Property used to set or get whether the dialog box display the color choice.
To display the dialog box to the user, call the ShowDialog() method.
click the FontDialog button from toolbox it will take place below the form and take two control text box and button to the form .
Now, double click on the button named color in the form and write the following code.
Private Sub cmdFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFont.Click
FontDialog1.ShowColor = True
textBox4.Font = FontDialog1.Font
textBox4.ForeColor = FontDialog1.Color
Now press Ctrl+F5 to run the application.
The below window will appear and we write some text on the text box and than and then click on the button named color.
Now select the color and font from the color box and click on the button OK and color and font will display on the textbox.
We choose color red and font size 12 from the color box and click on the button OK. textbox text will display as shown below.