Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Colorize listview item (2000 sr-1)

    Hi have see is possible to colorize a listitems with:
    ListView1.ListItems(1).ForeColor = vbRed

    but refered thias piece of code how to colorize antire line of listview line in this mode:
    if left character of REC ="APERTO" the colorize Vbred elsee VbBlue
    is possible.

    ...............
    Do Until EOF(1)

    Line Input #1, REC
    Set itmX = ListView1.ListItems.Add(, , Left(REC, 6))
    itmX.SubItems(1) = UCase(Trim(Mid(REC, 11, 10)))
    itmX.SubItems(2) = UCase(Trim(Mid(REC, 22, 8)))
    itmX.SubItems(3) = UCase(Trim(Mid(REC, 44, 7)))
    itmX.SubItems(4) = UCase(Trim(Mid(REC, 67, 11)))
    itmX.SubItems(5) = UCase(Trim(Mid(REC, 78, 7)))
    RIGA = RIGA + 1
    'DoEvents
    Label2.Caption = RIGA

    Loop
    ..............

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Colorize listview item (2000 sr-1)


  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Colorize listview item (2000 sr-1)

    used this but for "CHIUSO" hgave only the first value in frist column colored blue and not entire line!!!!

    Do Until EOF(1)

    Line Input #1, REC
    Set itmX = ListView1.ListItems.Add(, , Left(REC, 6))
    itmX.SubItems(1) = UCase(Trim(Mid(REC, 11, 10)))
    itmX.SubItems(2) = UCase(Trim(Mid(REC, 22, 8)))
    itmX.SubItems(3) = UCase(Trim(Mid(REC, 44, 7)))
    itmX.SubItems(4) = UCase(Trim(Mid(REC, 67, 11)))
    itmX.SubItems(5) = UCase(Trim(Mid(REC, 78, 7)))
    RIGA = RIGA + 1
    'DoEvents
    Label2.Caption = RIGA
    If Left(REC, 6) = "APERTO" Then
    itmX.ForeColor = vbRed
    For i=1 to 5
    itmX.ListSubItems(i).ForeColor = vbRed
    Next i
    Else
    itmX.ForeColor = vbBlue
    For i=1 to 5
    itmX.ListSubItems(i).ForeColor = vbBlue
    Next i
    End If

    Loop

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Colorize listview item (2000 sr-1)

    Try this somewhat shorter version

    Dim lngColor As Long
    If Left(REC, 6) = "APERTO" Then
    lngColor = vbRed
    Else
    lngColor = vbBlue
    End If
    Do Until EOF(1)
    Line Input #1, REC
    With ListView1.ListItems.Add(, , Left(REC, 6))
    .ForeColor = lngColor
    .SubItems(1) = UCase(Trim(Mid(REC, 11, 10)))
    .SubItems(2) = UCase(Trim(Mid(REC, 22, 8)))
    .SubItems(3) = UCase(Trim(Mid(REC, 44, 7)))
    .SubItems(4) = UCase(Trim(Mid(REC, 67, 11)))
    .SubItems(5) = UCase(Trim(Mid(REC, 78, 7)))
    For i = 1 To 5
    .ListSubItems(i).ForeColor = lngColor
    Next i
    RIGA = RIGA + 1
    Label2.Caption = RIGA
    End With
    Loop

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Colorize listview item (2000 sr-1)

    I see all item in blu and only in the first column of listview...

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Colorize listview item (2000 sr-1)

    I tried the code and it colored the rows correctly, so without seeing your workbook I don't know why it doesn't work for you.

  7. #7
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Colorize listview item (2000 sr-1)

    Peraph or i'm stupid or my head fired!!!!!!!!!
    test with this
    Tks for patience

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Colorize listview item (2000 sr-1)

    Sorry, I made a stupid mistake - I copied some of the code to the wrong place. The part that sets the color should be within the loop:

    Do Until EOF(1)
    Line Input #1, REC
    If Left(REC, 6) = "APERTO" Then
    lngColor = vbRed
    Else
    lngColor = vbBlue
    End If
    With ListView1.ListItems.Add(, , Left(REC, 6))
    .ForeColor = lngColor
    .SubItems(1) = UCase(Trim(Mid(REC, 11, 10)))
    .SubItems(2) = UCase(Trim(Mid(REC, 22, 8)))
    .SubItems(3) = UCase(Trim(Mid(REC, 44, 7)))
    .SubItems(4) = UCase(Trim(Mid(REC, 67, 11)))
    .SubItems(5) = UCase(Trim(Mid(REC, 78, 7)))
    For I = 1 To 5
    .ListSubItems(I).ForeColor = lngColor
    Next I
    RIGA = RIGA + 1
    Label2.Caption = RIGA
    End With
    Loop

  9. #9
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Colorize listview item (2000 sr-1)

    no sorry...now work EXCELLENT!

  10. #10
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Colorize listview item (2000 sr-1)

    work and not work!!!
    i dont understand why "CHIUSO" is colored only the first column....(?!)

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Colorize listview item (2000 sr-1)

    Works OK for me...

  12. #12
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Colorize listview item (2000 sr-1)

    <P ID="nt"><font size=-1>(No Text)</font>

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Colorize listview item (2000 sr-1)

    Sorry, no idea. The code is correct.

  14. #14
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Colorize listview item (2000 sr-1)

    wow!!!
    inverted color from the condition...
    ok for RED... but for BLUE not colorize

  15. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Colorize listview item (2000 sr-1)

    What happens if you replace vbBlue with RGB(0, 0, 255) ?
    Or if you replace it with vbGreen?

Page 1 of 2 12 LastLast

Posting Permissions

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