CodeItBetter Programming Another VB Programming Blog

How to Colour a Listview Item or SubItem

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'Controls - How to Colour a Listview Item or SubItem
Option Explicit
 
Public Sub ColorListviewRow(ByVal lv As ListView, ByVal RowNbr As Long, ByVal RowColor As OLE_COLOR)
    Dim itmX As ListItem
    Dim lvSI As ListSubItem
    Dim intIndex As Integer
 
    On Error GoTo ColorListviewRow_Error
 
    Set itmX = lv.ListItems(RowNbr)
    itmX.ForeColor = RowColor
    For intIndex = 1 To lv.ColumnHeaders.Count - 1
        Set lvSI = itmX.ListSubItems(intIndex)
        lvSI.ForeColor = RowColor
    Next intIndex
    Set itmX = Nothing
    Set lvSI = Nothing
 
ExitHere:
    On Error GoTo 0
    Exit Sub
 
ColorListviewRow_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ColorListviewRow of Form Form1"
End Sub
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.