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 / C++ / MFC
  4. C# combo box text color change

C# combo box text color change

Scheduled Pinned Locked Moved C / C++ / MFC
csharpdatabasehelp
2 Posts 2 Posters 1 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.
  • C Offline
    C Offline
    czaar999
    wrote on last edited by
    #1

    String Area = AreaCBox.Text;
    DAL.CaseBarCode csbrt = new DAL.CaseBarCode();
    System.Data.DataSet csbrs = csbrt.GetPO(Area);
    foreach (DataRow dr in csbrs.Tables[0].Rows)
    {

                POCBox.Items.Add(dr\["ProductionOrder"\]);
          
            }
    

    Hello, In the above the code I am calling a stored procedure(csbrt.GetPO(Area)) which retrieves two values "ProductionOrder" and "colorflag" columns. I am inserting ProductionOrder into 'POCBox' combobox. Now my requirement is to color the text for ProductionOrder in the combobox to green if the colorflag value is 0 and color it red if the colorflag value is 1. Please help with the code. Thanks in advance.

    Richard Andrew x64R 1 Reply Last reply
    0
    • C czaar999

      String Area = AreaCBox.Text;
      DAL.CaseBarCode csbrt = new DAL.CaseBarCode();
      System.Data.DataSet csbrs = csbrt.GetPO(Area);
      foreach (DataRow dr in csbrs.Tables[0].Rows)
      {

                  POCBox.Items.Add(dr\["ProductionOrder"\]);
            
              }
      

      Hello, In the above the code I am calling a stored procedure(csbrt.GetPO(Area)) which retrieves two values "ProductionOrder" and "colorflag" columns. I am inserting ProductionOrder into 'POCBox' combobox. Now my requirement is to color the text for ProductionOrder in the combobox to green if the colorflag value is 0 and color it red if the colorflag value is 1. Please help with the code. Thanks in advance.

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      What you want is called an "owner drawn" combobox. There's a great article right here on CP that explains how to do it with all the code you need: Implementing an OwnerDrawn ComboBox[^] And by the way, you posted this in the C++ forum instead of the C# forum where it belongs. :)

      The difficult we do right away... ...the impossible takes slightly longer.

      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