我想让listview的行能够被2整除时这行的背景色颜色是红色,否则的话背景色就是绿色。
Public Function LvwAltLinesBackground(ListView As ListView, PictureBox As PictureBox, Optional ByVal BackColorFirst As Boolean, Optional ByVal AltLineBackColor As OLE_COLOR = -1) As StdPicture
Dim nHeight As Single
Dim nScaleWidth As Single
Dim nAltLineBackColor As OLE_COLOR
With ListView
If .View = lvwReport Then
If .ListItems.count Then
.PictureAlignment = lvwTile
nHeight = .ListItems(1).Height
With PictureBox
.Visible = False
.Cls
If AltLineBackColor = -1 Then
nAltLineBackColor = .BackColor
Else
nAltLineBackColor = AltLineBackColor
End If
.BackColor = ListView.BackColor
.BorderStyle = 0
.Height = nHeight * 2
.Width = 10 * Screen.TwipsPerPixelX
nScaleWidth = .ScaleWidth
.AutoRedraw = True
If BackColorFirst Then
PictureBox.Line (0, nHeight)-Step(nScaleWidth, nHeight), nAltLineBackColor, BF
Else
PictureBox.Line (0, 0)-Step(nScaleWidth, nHeight - Screen.TwipsPerPixelY), nAltLineBackColor, BF
End If
Set ListView.Picture = Nothing
Set ListView.Picture = .Image
Set LvwAltLinesBackground = .Image
.AutoRedraw = False
If AltLineBackColor = -1 Then
.BackColor = nAltLineBackColor
End If
End With
.Refresh
Exit Function
End If
End If
Set .Picture = Nothing
End With
End Function