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.
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.
||The AllowFullOpen property enables the user to set custom colors in Windows Forms by setting values in the color dialog box.
||The Color property is used to set or get the user's selected color from the Color Dialog box.
||The FullOpen property is used to set a value representing whether the custom colors will be displayed when the dialog box is opened.
||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 property enables the user to display the help button in the Color Dialog box by setting a value in the dialog box.
||It is used to set the custom colors that are displayed on the dialog box.
||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
||When control or component is terminated by calling the Dispose method, a Dispose event occurs.
||When a user clicks the help button of the Color dialog box, the HelpRequest event is called.
Methods of Color DialogBox
||The ShowDialog () method is used to run a common dialog box with the default setting.
||The Dispose() method is used to free all resources used by the Control or component in the Color Dialog Box.
||The Equals() method is used to check whether the current or defined object is the same.
||It is used to call the HelpRequest event in the dialog box.
||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.
||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.
When we click on the any of the three buttons, it opens the Color popup window, as shown below.
Click the OK button to display the colored Windows Form, as shown below.