Igor
Igor

Reputation: 329

Change color line in listview

How change color line in listview . for example if line == 4 then line is red

Upvotes: 4

Views: 35568

Answers (2)

r3su
r3su

Reputation: 264

If you want to go through the whole list and colour each item conditionally, then you can use:

foreach (ListViewItem lvw in myListView.Items)
{
    if (lvw.SubItems[x].ToString() == "True")
    {
        lvw.BackColor = Color.Red;
    }
}

Or if you always want to color the item at index 4:

myListView.Items[4].BackColor = Color.Red;

Upvotes: 12

Michal Klouda
Michal Klouda

Reputation: 14521

Might the answer be as simple as following?

listView1.Items[3].BackColor = Color.Red;

Upvotes: 1

Related Questions