public virtual void RemoveObjects(ICollection modelObjects)
{
if (this.InvokeRequired) {
this.Invoke((MethodInvoker)delegate() { this.RemoveObjects(modelObjects); });
return;
}
if (modelObjects == null)
return;
this.BeginUpdate();
try {
// Give the world a chance to cancel or change the added objects
ItemsRemovingEventArgs args = new ItemsRemovingEventArgs(modelObjects);
this.OnItemsRemoving(args);
if (args.Canceled)
return;
modelObjects = args.ObjectsToRemove;
this.TakeOwnershipOfObjects();
ArrayList ourObjects = ObjectListView.EnumerableToArray(this.Objects, false);
foreach (object modelObject in modelObjects) {
if (modelObject != null) {
// ReSharper disable PossibleMultipleEnumeration
ourObjects.Remove(modelObject);
// ReSharper restore PossibleMultipleEnumeration
int i = this.IndexOf(modelObject);
if (i >= 0)
this.Items.RemoveAt(i);
}
}
this.PostProcessRows();
// Tell the world that the list has changed
this.UnsubscribeNotifications(modelObjects);
this.OnItemsChanged(new ItemsChangedEventArgs());
} finally {
this.EndUpdate();
}
}