
Private Sub Command1_Click()
Dim item As ListItem
Set item = ListView1.ListItems.Add(, , Text1)
item.SubItems(1) = Text2
item.SubItems(2) = Text3
item.SubItems(3) = Text4
End Sub
Private Sub Form_Load()
With ListView1
.View = lvwReport
.ColumnHeaders.Add , , "a"
.ColumnHeaders.Add , , "b"
.ColumnHeaders.Add , , "c"
.ColumnHeaders.Add , , "d"
End With
End Sub
这个列表我也是刚学,只弄懂了怎么添加,列表的第一列是主项,通过ListItems.Add添加,其它列是该项目下子项,通过该主项的子项数组SubItems赋值,下标从1开始。
Delphi帮助中的说明Call Create to instantiate a TListItem object at
runtime. List items added to the list view at design time are created automatically. At runtime, use the Add method of the TListItems object to create a list item and add it to the list view.
调用Create函数来再运行时创建一个TListItem的实例.
ListItmes在设计时加入的项目(item)会被自动创建.
在运行时请使用Add函数来创建list item并把它增加到
list view中
所以了,用tempitem:=ListView1.Add;
不要用tempitem:=TListView1.Create(...)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)