Results 1 to 4 of 4

Thread: Coloring Listview - resolved

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    116

    Resolved Coloring Listview - resolved

    VB Code:
    1. ListView1.ListItems.Add(, , "element1").ForeColor = vbRed

    When i use this code to try to color a listview item it colors it blue no matter what forecolor i set it to. What am i doing wrong? Thanks
    Last edited by cx323; Apr 10th, 2006 at 07:33 PM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: Coloring Listview

    Try this instead:
    VB Code:
    1. Private Sub Form_Load()
    2. '==============================
    3. Dim i%, j%
    4. Dim ITM As MSComctlLib.ListItem
    5. Dim LSI As MSComctlLib.ListSubItem
    6.  
    7.     ListView1.FullRowSelect = True
    8.     ListView1.View = lvwReport
    9.    
    10.     With ListView1.ColumnHeaders
    11.         .Add , , "List Item"
    12.         For j = 1 To 3
    13.             .Add , , "Sub Item " & j
    14.         Next j
    15.     End With
    16.    
    17.     For i = 1 To 10
    18.         Set ITM = ListView1.ListItems.Add(, , "Listitem " & i)
    19.         ITM.ForeColor = IIf(i Mod 2 = 0, vbRed, vbBlue)
    20.         For j = 1 To 3
    21.             ITM.ListSubItems.Add , , "Subitem " & i & j
    22.             ITM.ListSubItems(j).ForeColor = ITM.ForeColor
    23.         Next j
    24.     Next
    25.  
    26. End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    116

    Re: Coloring Listview - resolved

    thanks i have it working now

  4. #4

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