Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Combo box updates - but in 2 clicks

Combo box updates - but in 2 clicks

Scheduled Pinned Locked Moved C#
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spd69
    wrote on last edited by
    #1

    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.

    S 1 Reply Last reply
    0
    • S spd69

      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.

      S Offline
      S Offline
      spd69
      wrote on last edited by
      #2

      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(); }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups