Hi, in the below script I have changed the font of the ListView row based on an expiration date. How can I keep the color of the font when the row is highlighted? For example, if my font is red for a specific row it turns to white when that row is selected.
Thanks for any help!
'Loop through records and see if colors need to be changed due to expiration date
For Counter = 1 To lstUser.ListItems.Count
Set Item = lstUser.ListItems.Item(Counter)
If CDate(Item.SubItems(11)) <= Date Then
If Item.Selected Then
lstUser.SelectedItem.ForeColor = vbRed
End If
Item.ForeColor = vbRed
Item.ListSubItems(1).ForeColor = vbRed
Item.ListSubItems(2).ForeColor = vbRed
Item.ListSubItems(3).ForeColor = vbRed
Item.ListSubItems(4).ForeColor = vbRed
Item.ListSubItems(5).ForeColor = vbRed
Item.ListSubItems(6).ForeColor = vbRed
Item.ListSubItems(7).ForeColor = vbRed
Item.ListSubItems(8).ForeColor = vbRed
Item.ListSubItems(9).ForeColor = vbRed
Item.ListSubItems(10).ForeColor = vbRed
Item.ListSubItems(11).ForeColor = vbRed
Item.ListSubItems(12).ForeColor = vbRed
ElseIf CDate(Item.SubItems(11)) < Date + 30 Then
lstUser.Item(Counter).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(1).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(2).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(3).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(4).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(5).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(6).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(7).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(8).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(9).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(10).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(11).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(12).ForeColor = RGB(255, 153, 0)
End If
Next Counter
Thanks for any help!
'Loop through records and see if colors need to be changed due to expiration date
For Counter = 1 To lstUser.ListItems.Count
Set Item = lstUser.ListItems.Item(Counter)
If CDate(Item.SubItems(11)) <= Date Then
If Item.Selected Then
lstUser.SelectedItem.ForeColor = vbRed
End If
Item.ForeColor = vbRed
Item.ListSubItems(1).ForeColor = vbRed
Item.ListSubItems(2).ForeColor = vbRed
Item.ListSubItems(3).ForeColor = vbRed
Item.ListSubItems(4).ForeColor = vbRed
Item.ListSubItems(5).ForeColor = vbRed
Item.ListSubItems(6).ForeColor = vbRed
Item.ListSubItems(7).ForeColor = vbRed
Item.ListSubItems(8).ForeColor = vbRed
Item.ListSubItems(9).ForeColor = vbRed
Item.ListSubItems(10).ForeColor = vbRed
Item.ListSubItems(11).ForeColor = vbRed
Item.ListSubItems(12).ForeColor = vbRed
ElseIf CDate(Item.SubItems(11)) < Date + 30 Then
lstUser.Item(Counter).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(1).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(2).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(3).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(4).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(5).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(6).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(7).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(8).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(9).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(10).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(11).ForeColor = RGB(255, 153, 0)
lstUser.Item(Counter).ListSubItems(12).ForeColor = RGB(255, 153, 0)
End If
Next Counter