Creating a color chooser

How to create control like the one in MS Office,from which the user choose a color Or how to fill a combobox with different colors


Answer this question

Creating a color chooser

  • Mike Riley

    there is a project at codeproject.com which provides a class you can use if you want a colour combo box.

    search for cComboBox

    it will give you all the named web colours. The code isnt perfect and does miss a couple of colours, due to some spelling mistakes, but if you search through the 'getcolorfromname' and 'getnamefromcolor' (or simaly named) methods you can correct them

  • yxrkt

    you can use color dialog like follow

    private void mybutton1_Click(object sender, EventArgs e)

    {

    ColorDialog cd = new ColorDialog();

    cd.ShowDialog();

    }



  • Brad11

    for combox you can use

    set combox drawmode to OwnerDrawFixed than add code at draw item event

    private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)

    {

    Rectangle r= e.Bounds;

    Font f=e.Font;

    string s = this.comboBox1.Items[e.Index].ToString();

    Graphics g = e.Graphics;

    g.FillRectangle(new SolidBrush(Color.FromName(s)), r);

    }



  • Creating a color chooser