This sub when called will color a ListView row.
Usage: (To make the 5th row of a ListView Red)VB Code:
Public Sub ColorListviewRow(lv As ListView, RowNbr As Long, RowColor As OLE_COLOR) '*************************************************************************** 'Purpose: Color a ListView Row 'Inputs : lv - The ListView ' RowNbr - The index of the row to be colored ' RowColor - The color to color it 'Outputs: None '*************************************************************************** Dim itmX As ListItem Dim lvSI As ListSubItem Dim intIndex As Integer On Error GoTo ErrorRoutine 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 Set itmX = Nothing Set lvSI = Nothing Exit Sub ErrorRoutine: MsgBox Err.Description End Sub
ColorListviewRow MyListView, 5, vbRed




Reply With Quote