Mega Code Archive

 
Categories / C# Tutorial / GUI Windows Forms
 

Display Color Dialog and get the selection

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; public class MainClass{     public static void Main() {         System.Windows.Forms.ColorDialog colorDlg = new System.Windows.Forms.ColorDialog();         Color currColor;                          colorDlg.AnyColor = true;         colorDlg.ShowHelp = true;         currColor = Color.BlueViolet;           if (colorDlg.ShowDialog() != DialogResult.Cancel)  {              currColor = colorDlg.Color;             // Show current color.              string strARGB = colorDlg.Color.ToString();              MessageBox.Show(strARGB, "Color is:");         }     } }