I know how to remove a single checkedItem
from checkedlistbox
. But now, I want to remove all the checked items in one go.
I tried this:
foreach (var item in List_Frente.CheckedItems)
{
List_Frente.Items.Remove(item);
}
But as you probably know, it gives me an error,saying that, List that this enumerator is bound to has been modified. An enumerator can only be used if the list does not change.
How may I remove all checkeditems
with a single click ?
foreach
. Use afor
. – CoryzaList_Frente.CheckedItems.ToList()
? if you can that will solve the problem – BraudToString()
=( – Decennaryforeach
uses an iterator. You cannot make changes to a collection while there is an active iterator. You cannot do this, in its current form, with aforeach
. – Coryzacheckeditems
without aforeach
? – Decennaryfor (i = 0; i < (List_Frente.Items.Count ; i++)
Check out this page: msdn.microsoft.com/en-us/library/e954th47.aspx – Coryza