Changing form background color from a combobox.

Discussion in 'C#' started by Arnos, Sep 9, 2010.

  1. Arnos

    Arnos New Member

    Joined:
    Sep 9, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hey,
    I'm trying to setup a combobox so a color selected will change the background.
    I know I can name each color and direct it to the color by using -
    Code:
    private void button1_Click(object sender, EventArgs e)
            {
                string strColor = comboBox1.Text;
                Graphics g = this.CreateGraphics();
                switch (strColor)
                {
                    {
                    case "AliceBlue":
                        g.FillEllipse(new SolidBrush(Color.AliceBlue), 0, 0, 320, 220);
                        break;
    
    - and copy and paste changing the "AliceBlue" names for each color.
    but I'm sure there would be a way to borrow that name from the combobox.
    for instant 'in any case put that case as the color'...

    any help would be greatly appreciated.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice