How to make elements in ListView different colors?

I have a ListView full of ListViewItems.

I want to emphasize some of them when a certain event occurs, so I am looking for a way to change the color of the list to something other than black (red will be amazing).

Is it possible to dynamically change the color of items in a ListView playlist by default?

If not, is there any simple way to otherwise emphasize elements dynamically?

+7
c # listview winforms
source share
1 answer

The color of the list item looks straight:

ListViewItem li = new ListViewItem(); li.ForeColor = Color.Red; li.Text = "Sample"; listView1.Items.Add(li); 

Changing the background color of the list view itself is just listView1.BackColor = Colors.Red;

Changing an item in a ListView:

 foreach(ListViewItem li in listView1) { if(li.Text = "Sample") { li.ForeColor = Color.Green; } } 
+17
source share

All Articles