Results 1 to 4 of 4

Thread: Change color of a listview subitem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Location
    UK
    Posts
    25
    Hi,

    Can anyone tell me how to change the colour of a sub item in the VB6 listview control ?

    Regards

    Phil

  2. #2
    Addicted Member Shrog's Avatar
    Join Date
    Aug 1999
    Location
    Darkest Africa
    Posts
    186

    Lightbulb ListItem and ListSubItems

    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

  3. #3
    Addicted Member Shrog's Avatar
    Join Date
    Aug 1999
    Location
    Darkest Africa
    Posts
    186
    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


  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 1999
    Location
    UK
    Posts
    25
    This works fine,

    Thanks very much for your help

    Best Regards,

    Phil

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width