- This topic shows how to make a popup color selector in C#
- To implement popup color selector in C#, you have to add a Button and a ColorDialog to the form dynamically.
ColorDialog Class – How to make a popup color selector in C#
- ColorDialog class represents a common dialog box that displays available colors along with controls that enable the user to define custom colors.
- Syntax for ColorDialog
|
1 |
public class ColorDialog : CommonDialog |
- The inherited member ShowDialog must be invoked to create this specific common dialog box.
- HookProc can be overridden to implement specific dialog box hook functionality.
- Use Color to retrieve the color selected by the user.
Color Dialog Box (Windows) – How to make a popup color selector in C#
- Color Dialog Box displays a modal dialog box that allows the user to choose a specific color value.
- Then the user can choose a color from either a set of basic or custom color palettes.
- Alternatively, the user can generate a color value by modifying the RGB or hue, saturation, luminosity (HSL) color values of the dialog box user interface.
- The Color dialog box returns the RGB value of the color selected by the user.

How to make a popup color selector in C#
How to make a popup color selector in C# – Complete Code
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { ColorDialog CommonDialog1 = new ColorDialog(); // Pop up the Color Selector CommonDialog1.ShowDialog (); // Paint the from with the chosen color. // CommonDialog1.Color holds the color that the user has selected. this.BackColor = CommonDialog1.Color; // exit the Command1_Click() sub return; } } } |
If you have suggestions or doubts, please contact us…
How to make a popup color selector in C#






