vb中listview的列表格式里面的列名怎么设置
发布网友
发布时间:2023-03-18 15:05
我来回答
共1个回答
热心网友
时间:2023-11-10 05:53
д孤雁亦孇飞 说的对
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 答案补充 ~~~错了,三个按钮。。。