问题
I want to color each list view cell's BackColor using a different color. Is this possible?
回答1:
To change the colour of a cell's BackColor, you can do this:
listView1.Items[0].UseItemStyleForSubItems = false;
listView1.Items[0].SubItems[0].BackColor = Color.Green;
listView1.Items[0].SubItems[1].BackColor = Color.Orange;
listView1.Items[0].SubItems[2].BackColor = Color.Red;
// Change the 0 in Items[0] for whatever row you want,
// and the 0, 1 or 2 in SubItems[0] to whatever column you want.
The first line,
listView1.Items[0].UseItemStyleForSubItems = false;
Will make it so that the row of cells is not all coloured the same colour.
Here is a demo picture:
Hope this helps!
回答2:
If you use this property, then it works:
myListView.Items[i].UseItemStyleForSubItems = false;
来源:https://stackoverflow.com/questions/10958171/is-there-a-way-to-set-the-backcolor-of-winforms-listview-cells-individually