0

So I basicly have a textbox, combobox, listbox and button. When I'd like to change the backcolor of the combobox, i'd select the "combobox" in combobox and then choose the option "backcolor" in the listbox. Textbox is for typing the value (for example "red") in and when i'd press the button, the backcolor of the combobox would change to red.

So far I have this:

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            switch (comboBox1.SelectedIndex)
            {
                case 0:
                    listBox1.Items.Add("BackColor");
                    if (listBox1.SelectedIndex == 0 && textBox1.Text=="red")   
                    {   
                        //????
                    }
                    listBox1.Items.Add("Font");
                    listBox1.Items.Add("ForeColor");
                    listBox1.Items.Add("Font style");
                    break;

How do I make that happen?

L2PA
  • 35
  • 1
  • 7
  • have a look at http://stackoverflow.com/questions/13212179/changing-the-color-of-combobox-highlighting there might be some ideas for your case – mcy Oct 12 '13 at 10:13
  • @mcy I don't think that code is really for my situation.. – L2PA Oct 12 '13 at 10:18
  • Can anyone atleast give me a hint how to do it? :/ – L2PA Oct 12 '13 at 10:36
  • 1
    There just point to writing code like this, use the PropertyGrid control. If this is homework then you're supposed to figure out by yourself that the if() statement belongs in the button's Click event handler. – Hans Passant Oct 12 '13 at 10:48

0 Answers0