Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 根据项目显示成员向组合框列表项目添加不同颜色_C#_Winforms_Combobox - Fatal编程技术网

C# 根据项目显示成员向组合框列表项目添加不同颜色

C# 根据项目显示成员向组合框列表项目添加不同颜色,c#,winforms,combobox,C#,Winforms,Combobox,我将我的组合框与数据库中的选定项绑定,如下所示 DataTable Dt = CashCounterCls.GetAllCashCounterAll(); cmbcashcounter.DataSource = Dt; cmbcashcounter.ValueMember = "Counter_Id"; cmbcashcounter.DisplayMember = "FullName"; 我需要

我将我的组合框与数据库中的选定项绑定,如下所示

   DataTable Dt = CashCounterCls.GetAllCashCounterAll();           
            cmbcashcounter.DataSource = Dt;
            cmbcashcounter.ValueMember = "Counter_Id";
            cmbcashcounter.DisplayMember = "FullName";
我需要根据组合框包含的文本更改组合框中显示项的颜色。
也就是说,如果它包含“打开”文本,我需要在填充组合框后以绿色显示该列表项,则可以选中每个项并转换其颜色

你可以试试下面的代码

For Each i As ListViewItem In cmbcashcounter.Items
            If (i.Text = "open") Then
                i.ForeColor = Color.Green
            End If

 Next

必须使用自定义手动绘图。喜欢。@Alexander Petrov谢谢你的推荐。让我试试看