I am trying to change the fore color for certain columns based on there value in a listview subitem. I have tried various options and looked at various posts on SO but nothing seems to work.
In my present code, instead of changing dr(9) it is changing dr(0). Where have I gone wrong. Thanks
Using dr = oledbCmd.ExecuteReader()
'clear items in the list before populating with new values
'lvRequests.Items.Clear()
While dr.Read()
If dr.HasRows Then
Dim LVI As New ListViewItem
With LVI
.UseItemStyleForSubItems = False
.Text = dr(0).ToString()
.SubItems.Add(CDate(dr(5)).ToShortDateString())
.SubItems.Add(dr(1).ToString())
.SubItems.Add(dr(3).ToString())
If dr(3).ToString = "D" Then
.SubItems(3).Text = "Destroyed"
ElseIf dr(3).ToString = "O" Then
.SubItems(3).Text = "Out"
ElseIf dr(3).ToString = "I" Then
.SubItems(3).Text = "Intake"
End If
.SubItems.Add(dr(9).ToString())
If IsDBNull(dr(9)) Then
.SubItems(LVI.SubItems.Count - 1).Text = "O/S"
.ForeColor = Color.DarkRed
ElseIf dr(9) IsNot "DEMO" Then
.SubItems(LVI.SubItems.Count - 1).Text = "Done"
End If
End With
lvRequests.Items.Add(LVI)
lvcount += 1
End If
End While
End Using