Combo box updates - but in 2 clicks
-
I have a series of combo boxes (17 in all) each with a list of names for selection. Each name has its own colour. The names reflect who is/could be on duty during a particular time period. So when I select Barbara from the list in combo 1 I want that combo's text background colour to be set to light blue. If Gretchen is selected in combo 2 I want to use light green in combo 2. I have a click event which manages this part. using a case statement to detemine name/colour. When I load the combo box at program start up, everything is fine,each person has their own colour. If I now change the name in combo 2 from gretchen (green) to Sabrina (light salmon) The text changes but the colour does not. If I click on another combo box or again in the same combo box then the colour for Sabrina changes. Am I missing something.
-
I have a series of combo boxes (17 in all) each with a list of names for selection. Each name has its own colour. The names reflect who is/could be on duty during a particular time period. So when I select Barbara from the list in combo 1 I want that combo's text background colour to be set to light blue. If Gretchen is selected in combo 2 I want to use light green in combo 2. I have a click event which manages this part. using a case statement to detemine name/colour. When I load the combo box at program start up, everything is fine,each person has their own colour. If I now change the name in combo 2 from gretchen (green) to Sabrina (light salmon) The text changes but the colour does not. If I click on another combo box or again in the same combo box then the colour for Sabrina changes. Am I missing something.
Here is the code in the Event Handler private void cboCMs_EventHandler(object sender, EventArgs e) { ComboBox box = sender as ComboBox; box.SuspendLayout(); switch (box.Text) { case "Barbara": box.BackColor = System.Drawing.Color.LightBlue; break; case "Gretchen": box.BackColor = System.Drawing.Color.LightGreen; break; case "Sabrina": box.BackColor = System.Drawing.Color.LightYellow; break; case "Joanne": box.BackColor = System.Drawing.Color.LightPink; break; case "Not Played": box.BackColor = System.Drawing.Color.LightSalmon; break; case "No CM": box.BackColor = System.Drawing.Color.Magenta; break; case "No BR": box.BackColor = System.Drawing.Color.MediumOrchid; break; default: break; } box.Update(); box.ResumeLayout(); }