/// <summary> /// Raises the <see cref="E:ItemsRemoving"/> event. /// </summary> /// <param name="e">The <see cref="ItemsRemovingEventArgs"/> instance containing the event data.</param> protected virtual void OnItemsRemoving(ItemsRemovingEventArgs e) { if (this.ItemsRemoving != null) { this.ItemsRemoving(this, e); } }
/// <summary> /// Remove all of the given objects from the control /// </summary> /// <param name="modelObjects">Collection of objects to be removed</param> /// <remarks> /// <para>Nulls and model objects that are not in the ListView are silently ignored.</para> /// <para>Due to problems in the underlying ListView, if you remove all the objects from /// the control using this method and the list scroll vertically when you do so, /// then when you subsequenially add more objects to the control, /// the vertical scroll bar will become confused and the control will draw one or more /// blank lines at the top of the list. </para> /// </remarks> public override void RemoveObjects(ICollection modelObjects) { if (DataSource == null || modelObjects == null || modelObjects.Count == 0) { return; } // Give the world a chance to cancel or change the removed objects var args = new ItemsRemovingEventArgs(modelObjects); OnItemsRemoving(args); if (args.Canceled) { return; } ClearCachedInfo(); DataSource.RemoveObjects(args.ObjectsToRemove); UpdateVirtualListSize(); }