/// <summary> /// Raises the <see cref="E:ItemsAdding"/> event. /// </summary> /// <param name="e">The <see cref="ItemsAddingEventArgs"/> instance containing the event data.</param> protected virtual void OnItemsAdding(ItemsAddingEventArgs e) { if (this.ItemsAdding != null) { this.ItemsAdding(this, e); } }
/// <summary> /// Add the given collection of model objects to this control. /// </summary> /// <param name="modelObjects">A collection of model objects</param> /// <remarks> /// <para>The added objects will appear in their correct sort position, if sorting /// is active. Otherwise, they will appear at the end of the list.</para> /// <para>No check is performed to see if any of the objects are already in the ListView.</para> /// <para>Null objects are silently ignored.</para> /// </remarks> public override void AddObjects(ICollection modelObjects) { if (DataSource == null || modelObjects == null || modelObjects.Count == 0) { return; } // Give the world a chance to cancel or change the added objects var args = new ItemsAddingEventArgs(modelObjects); OnItemsAdding(args); if (args.Canceled) { return; } ClearCachedInfo(); DataSource.AddObjects(args.ObjectsToAdd); Sort(); UpdateVirtualListSize(); }