二:(name名) lv.Columns[列的索引].Name = "要设置的列名"
ListViewItem li=new ListViewItem(“类型名称”)li.SubItem.Add("价格")
li.SubItem.Add("价格")
li.SubItem.Add("价格")
li.SubItem.Add("价格")
listview1.Items.add(li)就可以了
д孤雁亦孇飞 说的对ListView的View必须是lvwReport才能显示表头。
下面给你段ListView的 *** 作代码
你往窗体上画两个按钮,一个ListView
Dim i As Long
Private Sub Command1_Click()
ListView1.ColumnHeaders.Add , , "第 " &ListView1.ColumnHeaders.Count + 1 &"项"
For i = 0 To ListView1.ColumnHeaders.Count - 1
ListView1.ColumnHeaders(i + 1).Width = (ListView1.Width - 100) / ListView1.ColumnHeaders.Count
Next
End Sub
Private Sub Command2_Click()
ListView1.ListItems.Add , , "第 " &ListView1.ListItems.Count + 1 &"表"
For i = 1 To ListView1.ColumnHeaders.Count - 1
ListView1.ListItems(ListView1.ListItems.Count).ListSubItems.Add , , i
Next
End Sub
Private Sub Command3_Click()
ListView1.ListItems.Remove ListView1.SelectedItem.Index
End Sub
Private Sub Form_Load()
ListView1.LabelEdit = lvwAutomatic
ListView1.View = lvwReport
Me.Move Left, Top, 5775, 5205
ListView1.Move 0, 0, Me.Width - 130, Me.Height - 1200
Command1.Move 720, 4000, 1095, 375
Command2.Move 2160, 4000, 1095, 375
Command3.Move 3600, 4000, 1095, 375
Command1.Caption = "添加项"
Command2.Caption = "添加表"
Command3.Caption = "删除选定表"
End Sub 答案补充 ~~~错了,三个按钮。。。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)