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

Related posts:

  1. How to scroll for selected ListView item
  2. Duplicate Listview Item Remover
  3. How to select entire Row in List View
  4. How to identify the selected items in listview
  5. How to kill duplicates in Listview control
  6. How to Read a file and add each line to an array of strings
  7. How to write a string array to a text file
  8. How to check whether an item exists in a collection
  9. How to Draw 3D text on form
  10. How to Retrieve the File Name from a Path

Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.