C# 如何获取listview里面当前选中的item

2024-12-12 05:36:08
推荐回答(3个)
回答1:

方法二:
private object GetSelectedItemFromListView(ListView listView)
{
return listView.SelectedItems[0];
}

方法一:
private object GetSelectedItemFromListView(ListView listView)
{
SelectedListViewItemCollection selListViewItemCol = listView.SelectedItems;
IEnumerator enumer = selListViewItemCol.GetEnumerator();
return enumer.Current();
}

回答2:

foreach (ListViewItem item in listView1.Items)
{
if (item.Checked)
{

}
}

回答3:

if( listview.SelectedItems!=null){
return listview.SelectedItems[0];
}