Listview Subitems Forecolor

252 Views Asked by At

How to change forecolor for all subitems in listview.

I have 2 columns, I need column 1 white, and second (subitems) column gray color.

tried this after setting gray color from items & subitems UI,

listView1.Items[0].UseItemStyleForSubItems = false;

but not working for items[1].

Any solutions?

Thanks

1

There are 1 best solutions below

0
Srijon Chakraborty On BEST ANSWER

I have checked that code. It is working. I think it will work for you too. A detail discussion is available in the given link. Thank you.

for (int i = 0; i < listView1.Items.Count; i++)
{
   listView1.Items[i].UseItemStyleForSubItems = false;
   listView1.Items[i].SubItems[0].ForeColor = System.Drawing.Color.White;
   listView1.Items[i].SubItems[1].ForeColor = System.Drawing.Color.Gray;
}

Addional Information: There is a very similar question is available on that link. Please check the provided link: How can I change the ForeColor of a single sub item in a ListView control?