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