改变VB listview 某一行背景色问题
现在有两个按钮,功能都是向listview中添加行,要求按钮1添加的行字体是红色,按钮2添加的行的字体是黑色,这段代码该怎么写呢?...
现在有两个按钮,功能都是向 listview中添加行, 要求按钮1添加的行字体是红色,按钮2添加的行的字体是黑色,这段代码该怎么写呢?
展开
展开全部
'参考代码
Private Sub Form_Load()
With ListView1
.View = lvwReport
.GridLines = True
.FlatScrollBar = False
.FullRowSelect = True
.ColumnHeaders.Add , "A", "111", 1000
.ColumnHeaders.Add , "B", "222", 1000
.ColumnHeaders.Add , "C", "333", 1000
End With
End Sub
Private Sub Command1_Click()
Dim i As Long
With ListView1
With .ListItems.Add
.ForeColor = RGB(255, 0, 0)
.Text = "123"
For i = 1 To ListView1.ColumnHeaders.Count - 1
.SubItems(i) = "123"
.ListSubItems(i).ForeColor = RGB(255, 0, 0)
Next i
End With
End With
End Sub
Private Sub Command2_Click()
Dim i As Long
With ListView1
With .ListItems.Add
.ForeColor = RGB(0, 0, 255)
.Text = "234"
For i = 1 To ListView1.ColumnHeaders.Count - 1
.SubItems(i) = "234"
.ListSubItems(i).ForeColor = RGB(0, 0, 255)
Next i
End With
End With
End Sub
Private Sub Form_Load()
With ListView1
.View = lvwReport
.GridLines = True
.FlatScrollBar = False
.FullRowSelect = True
.ColumnHeaders.Add , "A", "111", 1000
.ColumnHeaders.Add , "B", "222", 1000
.ColumnHeaders.Add , "C", "333", 1000
End With
End Sub
Private Sub Command1_Click()
Dim i As Long
With ListView1
With .ListItems.Add
.ForeColor = RGB(255, 0, 0)
.Text = "123"
For i = 1 To ListView1.ColumnHeaders.Count - 1
.SubItems(i) = "123"
.ListSubItems(i).ForeColor = RGB(255, 0, 0)
Next i
End With
End With
End Sub
Private Sub Command2_Click()
Dim i As Long
With ListView1
With .ListItems.Add
.ForeColor = RGB(0, 0, 255)
.Text = "234"
For i = 1 To ListView1.ColumnHeaders.Count - 1
.SubItems(i) = "234"
.ListSubItems(i).ForeColor = RGB(0, 0, 255)
Next i
End With
End With
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询