Listview font color

  • Thread starter Thread starter Kay
  • Start date Start date
K

Kay

Hi all,

I have a listview to display data from a datareader, while theReader is
lopping, how do I change the font color(for the whole row) depending on a
value of a column?

I'm trying to do something like this: (obviously it's not working...)

Do While theReader.Read
itmx = New ListViewItem
itmx.Text = (theReader("Cancel"))
If theReader("Cancel") = "Y" then
itmx.ForeColor.Green '<----------
else
itmx.ForeColor.Black '<----------
end if
lvwRoster.Items.Add(itmx)
Loop

Thanks!

Kay
 
Try something like this

Do While theReader.Read
itmx = New ListViewItem
itmx.Text = (theReader("Cancel"))
If theReader("Cancel") = "Y" then
itmx.ForeColor.Green '<----------
else
itmx.ForeColor.Black '<----------
end if

itmx.UseItemStyleForSubItems = true; //look here, do this or
else loop through the item's subitems and set each one's forecolor

lvwRoster.Items.Add(itmx)
Loop
 
Back
Top