How to change the backcolor of subitems in a listview programmatically?

on form load i want to change the backcolor of subitems from different rows and columns in a listview, how do i do that


Answer this question

How to change the backcolor of subitems in a listview programmatically?

  • Subi

    I found the problem.

    I forgot to set the UseItemStyleForSubItems to false.

    thanks.


  • Peter Johnston

    I am meeting this problem now.

    The solution can work fine if the listview1.Items[0].SubItems[0].Text != string.empty.

    However, if the text of subitem is empty, the BackColor = Color.LightBlue; can't work.

    I don't know why

    Can anybody give me some advice

    thanks.


  • Shawnee1111

    Change the BackColor property of an item, that will change the BackColor of the entire row:



    listView1.Items[0].BackColor = Color.LightBlue;



    Similar effect will happen if you changed the BackColor of a SubItem:



    listView1.Items[0].SubItems[0].BackColor = Color.LightBlue;



    You can loop through it to change the colors in alternating way.

    Regards,

    -chris

  • How to change the backcolor of subitems in a listview programmatically?