且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

帮助列表视图并从所选项目中获取子项目信息

更新时间:2023-11-16 23:00:40

要在ListView 中进行多项选择,您必须设置 ListView的属性为true.然后使用SelectedItems 属性,该属性返回SelectedListViewItemCollection
然后迭代此集合以获取每个子项目的Text 属性
For multiple selection in ListView you have to set the MultiSelect property of ListView to true. Then use the SelectedItems property, which returns SelectedListViewItemCollection
Then iterate this collection to get the Text property of each sub item
'In the form load event set
CAE_ListView.MultiSelect=True

'Iterate the selected items
Dim Msg as string=""
For Each sITEM as ListViewItem In CAE_Listview.SelectedItems
    Msg &= sITEM.Subitems(1).Text & VbCrLf
Next
MessageBox.Show(Msg)