I have a CheckedListBox previously populated. I want to loop with a \"for each / next\" through all items in the CheckedListBox and do a lot of \"stuff\" with each iteration
A CheckedListBox
is not a collection of CheckBox
controls.
It does not have a collection of wrapper objects.
The CheckedListBox control is a simple control that can only display a plain list of items; it sounds like you're looking for something more powerful. (For example, it is impossible to change the background color of an individual item without owner-drawing)
You should use a ListView
(with the CheckBoxes
property set to true) instead.
You can then loop through the ListViewItem
instances in its Items
collection.
For Each item In SuppliersCheckList.CheckedItems
If SuppliersCheckList.GetItemCheckState(SuppliersCheckList.Items.IndexOf(item)) Then
MsgBox(item.ToString)
End If
Next