This does not work because you are working with a copy of the list that you created by calling ToList()
.
BindingList<T>
does not support RemoveAll()
: it is only a List
function, therefore:
var itemToRemove = UserList.Where(x => x.id == ID).ToList(); foreach (var item in itemToRemove) UserList.Remove(item);
We call ToList()
here, because otherwise we will list the collection when it changes.
vc 74 source share