1
I have problems defining Subitem background color from listview when returning database query. I need that in the column n° 18, which will return values such as " Expired" and " In Day" when the returned value is = the "Expired" that ascend in column 18 is red. The code below colors the complete line.
foreach (ListViewItem item in lsvDados.Items)
{
if (item.SubItems[18].Text == "VENCIDO")
item.BackColor = System.Drawing.Color.Red;
else item.BackColor = System.Drawing.Color.Green;
}
The code below does not color anything.
foreach (ListViewItem item in lsvDados.Items)
{
if (item.SubItems[18].Text == "Vencido")
item.SubItems[18].BackColor = System.Drawing.Color.Red;
else
item.SubItems[18].BackColor =System.Drawing.Color.Green;
}
How do I color just the subitem with the desired value ? How would the code look to scan the entire listview looking for some subitem with this desired value and soon after find format it ?
@Emerson JS, The code formats only one value returned from the database. If select returns 3 lines, only 1 will be formatted. Because this occurs, should format all lines.
– Philipe Said