【发布时间】:2013-01-30 02:55:51
【问题描述】:
我正在尝试检查checkedlistbox 中的每个项目,并根据它是否被选中来处理该项目。我已经能够使用 indexCollection 获取已检查的项目,但我无法获取所有项目,我收到此错误“无法将“System.String”类型的对象转换为“System.String”类型。 Windows.Forms.ListViewItem'
foreach (ListViewItem item in checkedListBox2.Items)
{
if (item.Checked == true)
//do something with item.name
else
//do something else with item.name
}
我不确定为什么它在 foreach 行中给我字符串转换错误。我怎样才能做到这一点?谢谢。
【问题讨论】:
标签: winforms foreach checkedlistbox