【发布时间】:2011-07-30 00:36:57
【问题描述】:
我在使用带有 WinForm ListView 控件的 foreach 语句时遇到了困难。以下两个代码块演示了我正在尝试做的事情。它适用于 for 循环,但不适用于 foreach。
foreach(var item in listView.Items){
item. <-Can't access any of the subitems of this item
}
对
for(int i=0;i<listView.Items.Count;i++){
listView.Items[i].Subitems[1] <- Here I can access the sub items
}
我正在尝试使用 foreach 循环,以便更轻松地从 ListView 中删除项目。
【问题讨论】:
标签: c# winforms listview foreach