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谢谢你的推荐。让我试试看