i'm trying to check each item in a checkedlistbox and do something with the item depending if it is checked or not. I've been able to just get the checked items with the indexCollection, but i'm having trouble getting all of the items, i'm getting this error 'Unable to cast object of type 'System.String' to type 'System.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
}
i'm unsure why it's giving me the string cast error in the foreach line. How can I accomplish this? Thanks.