Take a look at the SelectedItems property and repeat this to see which items are selected.
If you want to view all the elements, you can compare the two collections (MyListBox.Items and MyListBox.SelectedItems) and see which ones correspond.
sort of:
foreach(Item item in MyListBox.Items) if(MyListBox.SelectedItems.Contains(item) MyObject.Value = true; else MyObject.Value = false;
Overkil, though really! I suppose there is a goal, if you want to do something to all the elements that are not selected, is that what you want to do?
There are much better ways to do this, although Randolpho is the right one, data binding will be the best way to do this, depending on how your data is organized / entered and how big the list is.
Spud1 source share