Hi,
Can anyone tell me how to change the colour of a sub item in the VB6 listview control ?
Regards
Phil
Printable View
Hi,
Can anyone tell me how to change the colour of a sub item in the VB6 listview control ?
Regards
Phil
The ListItem itself has a ForeColor property, that will allow you to change the color. Unfortunately, there is no BackColor, so that remains unchanged.
The ListItem also has a collection of ListSubItems. Now unlike SubItems, which kust contains the text of the subitems, the ListSubItems exposes a whole lot of properties for the SubItems. Here you can set the ForeColor of each SubItem.
I hope this helps.
Shrog
http://Shrog.iwarp.com
Me again,
I just have to add that when you change the ListItem.ForeColor, the change shows automatically in the listview. When you change the ListSubItem.ForeColor, the chnage is not visible until the control refreshes, so you would want to do this after changing the color.
Private Sub Command1_Click()
Dim MyItem As ListItem
Dim MySubItem As ListSubItem
Set MyItem = ListView1.ListItems(lngIndex)
MyItem.ForeColor = vbRed
For Each MySubItem In MyItem.ListSubItems
MySubItem.ForeColor = vbRed
Next MySubItem
ListView1.Refresh
End Sub
This works fine,
Thanks very much for your help
Best Regards,
Phil