Here is code that rips through a file to set the color of a listview item color and subitem color.
This is VB6.   I found a lot of people asking how to do this, but no real solutions.  It's not that hard after you know what the syntax is;
Do Until EOF(fnum1)
    Line Input #fnum1, Linein
        aRRy = Split(Linein, ",")
            If UBound(aRRy) = 10 Then
                SSN = Trim$(Replace(aRRy(8), Chr$(34), vbNullString))
                Doctype = UCase(Replace(aRRy(9), Chr$(34), vbNullString))
                TIFfile = UCase(Replace(aRRy(7), Chr$(34), vbNullString))
                BatchID = Trim$(Replace(aRRy(10), Chr$(34), vbNullString))
      
                ListView.ListItems.Add , , SSN
                ListView.ListItems.Item(ListView.ListItems.Count).SubItems(1) = Doctype
                Debug.Print TIFfile
            
                ListView.ListItems.Item(ListView.ListItems.Count).SubItems(2) = TIFfile
                If Len(SSN) <> 9 Then
                    ListView.ListItems.Item(ListView.ListItems.Count).ForeColor = vbRed
                Else
                     ListView.ListItems.Item(ListView.ListItems.Count).ForeColor = vbBlack
                End If
                If EXIST(TIFfile) Then
                       ListView.ListItems.Item(ListView.ListItems.Count).ListSubItems.Item(2).ForeColor = vbBlack
                    Else
                       ListView.ListItems.Item(ListView.ListItems.Count).ListSubItems.Item(2).ForeColor = vbRed
                End If
                
            End If
Loop
Close #fnum1
 
No comments:
Post a Comment