ListView Subitem Forecolor problem

  • Thread starter Thread starter Tom John
  • Start date Start date
T

Tom John

Hi

I have a ListView that i want to be able to modify the color of
particular items depending on whether the value of the item they are
about to be replaced with is higher, lower or the same:

With QueueListItem.SubItems(ItemCount)
If .Text = DataRow.Item(ItemCount) Then
.ForeColor = Color.Black
ElseIf .Text < DataRow.Item(ItemCount) Then
.ForeColor = Color.Red
ElseIf .Text > DataRow.Item(ItemCount) Then
.ForeColor = Color.Green
End If
.Text = DataRow.Item(ItemCount)
End With

However the color of the items always remain black. If i stick a
message at the end:

msgbox(.ForeColor) it returns the colour i just set it to which is a
bit wierd i think.

Any ideas?

Thanks

Tom
 
It sounds like you might need to call Invalidate to get the control to
repaint.

Adios,
January
 
With Deft Fingers said:
I have a ListView that i want to be able to modify the color of
particular items depending on whether the value of the item they are
about to be replaced with is higher, lower or the same:

With QueueListItem.SubItems(ItemCount)
If .Text = DataRow.Item(ItemCount) Then
.ForeColor = Color.Black
ElseIf .Text < DataRow.Item(ItemCount) Then
.ForeColor = Color.Red
ElseIf .Text > DataRow.Item(ItemCount) Then
.ForeColor = Color.Green
End If
.Text = DataRow.Item(ItemCount)
End With

I think you need something like:

'Enables Show SubItems in Differnt Colours
LItem.UseItemStyleForSubItems = False

I had to use the above to have the background colours happen...

Regards,

Bruce
 
Back
Top