1个回答
推荐于2016-05-19
展开全部
Public Sub SetListViewColor(Lv As ListView, picBg As PictureBox, LvCount As Long)
'Author:深夜树阴
'DateTime:2005-05-18
'Description:更改LISTVIEW背景色
Dim i As Integer
Lv.ColumnHeaders.Clear
Lv.ListItems.Clear
Lv.ColumnHeaders.Add , "a", "test1", 100
Lv.ListItems.Add , "a1", "123" '取行宽
picBg.BackColor = Lv.BackColor
Lv.Parent.ScaleMode = vbTwips
picBg.ScaleMode = vbTwips
picBg.BorderStyle = vbBSNone
picBg.AutoRedraw = True
picBg.Visible = False
picBg.Width = Screen.Width '我LISTVIEW自调整所直接用屏幕宽度
picBg.Height = Lv.ListItems(1).Height * LvCount '取要添充高度
picBg.ScaleHeight = LvCount
picBg.ScaleWidth = 1
picBg.DrawWidth = 1
'-----------------------------
'画每行LISTVIEW颜色
'------------------------------
For i = 1 To LvCount
If i / 2 = Int(i / 2) Then
picBg.Line (0, i - 1)-(1, i), &HC0FFFF, BF
Else
picBg.Line (0, i - 1)-(1, i), 16777152, BF
End If
Next
Lv.Picture = picBg.Image
Lv.ColumnHeaders.Clear
Lv.ListItems.Clear
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询