Question

maybe someone can help me with this code.. I want to know, how can i change color for work "2" to Red, when this work exist.. and work 1, work 3, to Black. maybe its possible to set work "2" + name all row Red. Thank you very mutch, and sorry for my bad english :)

Was it helpful?

Solution

You can set the ForeColor of ListViewItem like this:

if (!name.StartsWith("unknown"))
{
    ListViewItem lvi = new ListViewItem(work + " " + name + " " + "\n\t");
    lvi.UseItemStyleForSubItems = false;
    if(work != "work 2"))
        lvi.ForeColor = Color.Black;
    else
        lvi.ForeColor = Color.Red;

    listView1.Items.Add(lvi);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top