문제

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 :)

도움이 되었습니까?

해결책

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top