用代码进行说一下:
Private Sub Command1_Click()
Dim xx As ListItem
If Text1.Text <> "" And Text2.Text <> "" And Text3.Text <> "" Then
Set xx = ListView1.ListItems.Add(, , Text1.Text)
xx.SubItems(1) = Text2.Text
xx.SubItems(2) = Text3.Text
Set xx = Nothing
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End If
End Sub
Private Sub Form_Load()
ListView1.View = lvwReport
ListView1.ColumnHeaders.Add , , "第1列", 1000
ListView1.ColumnHeaders.Add , , "第2列", 1000
ListView1.ColumnHeaders.Add , , "第3列", 1000
End Sub
listView1.Items[i].SubItems[j].Text 就是listview1 第i+1行 第j+1列的内容,textbox中的数据添加到listView中去 直接listView1.Items[i].SubItems[j].Text = textBox.text就行了
写数据库不会了可以继续问我
第一步:添加列头可在form_load里边添加,如下:
'初始化
ListView1.FullRowSelect
=
True
'(允许整行选择)
listview1.gridlines=true
'(显示网格)
listview1.checkboxs=true
'显示checkboxs框
listview1.view=3
'以报表形式显示
ListView1.ColumnHeaders.Clear
ListView1.ColumnHeaders.Add
1,
,
"姓名",
1000
ListView1.ColumnHeaders.Add
2,
,
"性别",
500
ListView1.ColumnHeaders.Add
3,
,
"职称",
1500
ListView1.ColumnHeaders.Add
4,
,
"电话",
1000
第二步,添加数据
Dim
itmX
As
ListItem
Set
itmX
=
lvw.ListItems.Add(参数,参数,参数,……)
'这些参数都可以为空,具体你可以看看msdn
itmX.text="李四"
itmX.SubItems(1)
=
"雄性"
itmX.SubItems(2)
=
"大将军"
itmX.SubItems(3)
=
"10086"
第三步,取得行数据
Private
Sub
ListView1_ItemClick(ByVal
Item
As
MSComctlLib.ListItem)
Text1
=
Item.Text
Text2
=
Item.SubItems(1)
Text3
=
Item.SubItems(2)
Text4
=
Item.SubItems(3)
End
Sub
试一试就能知道怎么用了,快去试试吧
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)