3

How can I change the colour of a specific column in a listview?

string[] row = { appID[i], "Launch Game"}; // more data to add

listView1.Items.Add(nameArray[i], i).SubItems.AddRange(row);

listView1.ForeColor = System.Drawing.Color.Blue;
M.Babcock
  • 18,753
  • 6
  • 54
  • 84
deepseapanda
  • 3,717
  • 8
  • 32
  • 39
  • [Related question](http://stackoverflow.com/questions/7620120/listview-subitems-font-not-working) – M.Babcock Apr 19 '12 at 19:01
  • Another related question is the one to color a single cell which can be found here. [Highlight cell](http://stackoverflow.com/questions/215248/c-sharp-listview-detail-highlight-a-single-cell) – Rutix Apr 19 '12 at 19:06

1 Answers1

16

Try something like this:

ListViewItem item1 = new ListViewItem( "Item 1"); 
item1.SubItems.Add( "Color" ); 
item1.SubItems[1].ForeColor = System.Drawing.Color.Blue;
item1.UseItemStyleForSubItems = false; 
listView1.Items.Add( item1 ); 

If you are using database to bind it you may have to do this during on item databind process. Let me know if that's the case.

Lukas
  • 2,885
  • 2
  • 29
  • 31