vb中listview控件怎么设置某一行的背景色
1个回答
展开全部
刚好我写了一个,因为我自己需要用到呵..不过老实说,listview有选中的效果,那个应该 就能满足你的要求:
Option Explicit
Private WithEvents bc As PictureBox
Private Sub Command1_Click()
Call SetLineBackColor(ListView1, 3, &HE0E0E0)
End Sub
Public Sub SetLineBackColor(Lv As ListView, LvLineCount As Long, LVBC As Long)'分别是listview的名称,第几行,背景色
Lv.Parent.ScaleMode = vbTwips
If bc Is Nothing Then
Set bc = Controls.Add("VB.PictureBox", "picbg")
End If
With bc
.Visible = True
.BackColor = Lv.BackColor
.ScaleMode = vbTwips
.BorderStyle = vbBSNone
.AutoRedraw = True
.Visible = False
.Width = Lv.Width
.Height = Lv.ListItems(1).Height * (LvLineCount + 1)
.ScaleHeight = LvLineCount + 1
.ScaleWidth = 1
.DrawWidth = 1
End With
bc.Line (0, LvLineCount - 1)-(1, LvLineCount), LVBC, BF
Lv.Picture = bc.Image
End Sub
Option Explicit
Private WithEvents bc As PictureBox
Private Sub Command1_Click()
Call SetLineBackColor(ListView1, 3, &HE0E0E0)
End Sub
Public Sub SetLineBackColor(Lv As ListView, LvLineCount As Long, LVBC As Long)'分别是listview的名称,第几行,背景色
Lv.Parent.ScaleMode = vbTwips
If bc Is Nothing Then
Set bc = Controls.Add("VB.PictureBox", "picbg")
End If
With bc
.Visible = True
.BackColor = Lv.BackColor
.ScaleMode = vbTwips
.BorderStyle = vbBSNone
.AutoRedraw = True
.Visible = False
.Width = Lv.Width
.Height = Lv.ListItems(1).Height * (LvLineCount + 1)
.ScaleHeight = LvLineCount + 1
.ScaleWidth = 1
.DrawWidth = 1
End With
bc.Line (0, LvLineCount - 1)-(1, LvLineCount), LVBC, BF
Lv.Picture = bc.Image
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询