Home » VB.NET Color Dialog Box

VB.NET Color Dialog Box

by Online Tutorials Library

VB.NET Color Dialog Box

The Color Dialog box is used to display the Color dialog box and the selection of colors on the Microsoft Windows Application. It allows users to set or change the color of an object, such as the background color of a control or the color used to paint an object. Furthermore, the control dialog box also allows the facility to the user to create a new color by mixing all other colors of the Color Dialog Box.

Let’s create a Color Dialog in the VB.NET Windows form by using the following steps.

Step 1: Drag the Color Dialog from the toolbox and drop it to the Windows form, as shown below.

VB.NET Color Dialog Box

Step 2: Once the Color Dialog is added to the form, we can set various properties of the Color by clicking on the Color Dialog.

Properties of Color DialogBox

There are following properties of the Color Dialog Box in the Windows Form.

Properties Description
AllowFullOpen The AllowFullOpen property enables the user to set custom colors in Windows Forms by setting values in the color dialog box.
Color The Color property is used to set or get the user’s selected color from the Color Dialog box.
FullOpen The FullOpen property is used to set a value representing whether the custom colors will be displayed when the dialog box is opened.
AnyColor The AnyColor property takes a value that is used to display all available colors in the Color dialog box with a set of basic colors.
ShowHelp ShowHelp property enables the user to display the help button in the Color Dialog box by setting a value in the dialog box.
CustomColors It is used to set the custom colors that are displayed on the dialog box.
SolidColorOnly The SolidColorOnly property is used to set a value representing whether the dialog box restricts the user from selecting only solid colors.

Events of Color DialogBox

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 Color dialog box, the HelpRequest event is called.

Methods of Color DialogBox

Method Description
ShowDialog() The ShowDialog () method is used to run a common dialog box with the default setting.
Dispose() The Dispose() method is used to free all resources used by the Control or component in the Color Dialog Box.
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. For example, the last selected color to be black, and the custom color to be their default values.
RunDialog() It is used to override a derived class to create a common dialog box.

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

ColorDialog.vb

Output:

VB.NET Color Dialog Box

When we click on the any of the three buttons, it opens the Color popup window, as shown below.

VB.NET Color Dialog Box

Click the OK button to display the colored Windows Form, as shown below.

VB.NET Color Dialog Box


You may also like