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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top