1,451
社区成员
发帖
与我相关
我的任务
分享
Public Sub ListView_HColor(ByRef mListView As ListView, query As Form, lvcount As Long)
query.Picture1.ScaleMode = vbTwips
query.Picture1.BorderStyle = vbBSNone
query.Picture1.AutoRedraw = True
query.Picture1.Font = mListView.Font
iFontHeight = query.Picture1.TextHeight("b") + Screen.TwipsPerPixelY
iBarHeight = (iFontHeight * 1)
query.Picture1.Width = mListView.Width
'======
query.Picture1.Height = iBarHeight * 2
query.Picture1.ScaleMode = vbUser
query.Picture1.ScaleHeight = 2
query.Picture1.ScaleWidth = 1
'draw the actual bars
'query.Picture1.Line (0, 0)-(1, 1), &HC0FFFF, BF 'white bars - modify vbWhite To change bar color
'query.Picture1.Line (0, 1)-(1, 2), 16777152, BF 'light green bars - modify RGB(x,x,x) To change bar color
For i = 1 To lvcount
If i / 2 = Int(i / 2) Then
query.Picture1.Line (0, i - 1)-(1, i), &HC0FFFF, BF
Else
query.Picture1.Line (0, i - 1)-(1, i), 16777152, BF
End If
Next
'======
'put it in the listview control, tiled
mListView.PictureAlignment = lvwTile
mListView.Picture = query.Picture1.Image
End Sub
Public Sub SetListViewBgColor(lv As ListView, bgPic As PictureBox)
Dim i As Integer
Dim itmX As ListItem
Me.ScaleMode = vbTwips
bgPic.ScaleMode = vbTwips
With lv
.View = lvwReport
.FullRowSelect = True
.Font.Name = "Tahoma"
.ColumnHeaders.Add , , "This is Just a Simple Example"
.ColumnHeaders(1).Width = 4800
End With
With bgPic
.ScaleMode = vbTwips
.AutoRedraw = True
.BorderStyle = 0
'.Visible = False '这儿设置把PictureBox隐藏
.Font = lv.Font
.Width = lv.Width
Set itmX = lv.ListItems.Add() 'itmX.Text=//////////
.Height = itmX.Height * 2
Set itmX = Nothing
lv.ListItems.Clear
'用pictureBox画两条不一样颜色的长条拼一起,好用作ListView的背景图。
bgPic.Line (0, 0)-(.Width, .Height / 2), vbWhite, BF
bgPic.Line (0, .Height / 2)-(.Width, .Height), RGB(227, 241, 226), BF
lv.PictureAlignment = lvwTile
lv.Picture = .Image
End With
End Sub
Private Sub Form_Load()
SetListViewBgColor ListView1, Picture1
End Sub
query.Picture1.Font = mListView.Font --这里要加 Set,你可以 Debug 比较一下