C# : change listbox items color

前端 未结 3 547
死守一世寂寞
死守一世寂寞 2020-12-15 07:01

i am working on program on windows forms I have a listbox and I am validating data I want the correct data be added to the listbox with color green while the invalid data ad

3条回答
  •  别那么骄傲
    2020-12-15 07:19

    How about

                MyLB is a listbox
    
                Label ll = new Label();
                ll.Width = MyLB.Width;
                ll.Content = ss;
                if(//////)
                    ll.Background = Brushes.LightGreen;
                else
                    ll.Background = Brushes.LightPink;
                MyLB.Items.Add(ll);
    

提交回复
热议问题