BrightIdeasSoftware.ObjectListView.RemoveObjects C# (CSharp) Method

RemoveObjects() public method

Remove all of the given objects from the control.

Nulls and model objects that are not in the ListView are silently ignored.

This method is thread-safe.

public RemoveObjects ( ICollection modelObjects ) : void
modelObjects ICollection Collection of objects to be removed
return void
        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();
            }
        }
ObjectListView