I am trying to get all the items that are checked in a CheckedListBox when one of the check boxes is checked. I want to be able to do something with this list in the ItemCheck event.
The problem is that when you go into the event, the checkbox is not checked yet. So if I do a foreach loop on the *.Checked property, it won't be there if it was unchecked before the user checked it.
I could use the e.NewValue property, but how, since I don't know which index the item in the foreach is.
So if I do the following:
I don't see the one that was just checked because it isn't checked yet. Conversely, if the user unchecks an item, it WILL show up in the list, because it hasn't become unchecked yet.
Thanks,
Tom
The problem is that when you go into the event, the checkbox is not checked yet. So if I do a foreach loop on the *.Checked property, it won't be there if it was unchecked before the user checked it.
I could use the e.NewValue property, but how, since I don't know which index the item in the foreach is.
So if I do the following:
Code:
private void chkSelectStatementColumns_ItemCheck(object sender, ItemCheckEventArgs e)
{
foreach (var itemChecked in chkSelectStatementColumns.CheckedItems)
{
// Use the IndexOf method to get the index of an item.
MessageBox.Show(itemChecked.ToString());
}
}
Thanks,
Tom