比如 一个表格 就是vb listview 怎样通过按钮来添加一行 按一下添加一行 再按一下 又可以添加
展开全部
刚好我写了一个,因为我自己需要用到呵..不过老实说,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
展开全部
Dim i As Integer
Private Sub Command1_Click()
With ListView1.ListItems.Add
.SubItems(1) = i
End With
i = i + 1
End Sub
Private Sub Form_Load()
ListView1.View = lvwReport
ListView1.ColumnHeaders.Clear
With ListView1.ColumnHeaders
.Add , , "", 10
.Add , , "第一列", 1000
End With
i = 1
End Sub
Private Sub Command1_Click()
With ListView1.ListItems.Add
.SubItems(1) = i
End With
i = i + 1
End Sub
Private Sub Form_Load()
ListView1.View = lvwReport
ListView1.ColumnHeaders.Clear
With ListView1.ColumnHeaders
.Add , , "", 10
.Add , , "第一列", 1000
End With
i = 1
End Sub
来自:求助得到的回答
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询