protected virtual void OnItemsAdding(ItemsAddingEventArgs e) { if (this.ItemsAdding != null) { this.ItemsAdding(this, e); } }
/// <summary> /// Inserts the given collection of model objects to this control at hte given location /// </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 given position 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 InsertObjects(int index, ICollection <object> modelObjects) { if (VirtualListDataSource == null) { return; } // Give the world a chance to cancel or change the added objects ItemsAddingEventArgs args = new ItemsAddingEventArgs(index, modelObjects); OnItemsAdding(args); if (args.Canceled) { return; } try { BeginUpdate(); VirtualListDataSource.InsertObjects(index, args.ObjectsToAdd); BuildList(); } finally { EndUpdate(); } }
/// <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 (this.VirtualListDataSource == null) { return; } // Give the world a chance to cancel or change the added objects ItemsAddingEventArgs args = new ItemsAddingEventArgs(modelObjects); this.OnItemsAdding(args); if (args.Canceled) { return; } try { this.BeginUpdate(); this.VirtualListDataSource.AddObjects(args.ObjectsToAdd); this.BuildList(); } finally { this.EndUpdate(); } }
public override void AddObjects(ICollection modelObjects) { if (this.DataSource != null) { ItemsAddingEventArgs e = new ItemsAddingEventArgs(modelObjects); this.OnItemsAdding(e); if (!e.Canceled) { this.ClearCachedInfo(); this.DataSource.AddObjects(e.ObjectsToAdd); base.Sort(); this.UpdateVirtualListSize(); } } }
/// <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> override public void AddObjects(ICollection modelObjects) { if (this.DataSource == null) { return; } // Give the world a chance to cancel or change the added objects ItemsAddingEventArgs args = new ItemsAddingEventArgs(modelObjects); this.OnItemsAdding(args); if (args.Canceled) { return; } this.DataSource.AddObjects(args.ObjectsToAdd); this.UpdateVirtualListSize(); }
/// <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 (VirtualListDataSource == null) { 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(); VirtualListDataSource.AddObjects(args.ObjectsToAdd); Sort(); UpdateVirtualListSize(); }
/// <summary> /// Insert the given collection of objects before the given position /// </summary> /// <param name="index">Where to insert the objects</param> /// <param name="modelObjects">The objects to be inserted</param> /// <remarks> /// <para> /// This operation only makes sense of non-sorted, non-grouped /// lists, since any subsequent sort/group operation will rearrange /// the list. /// </para> /// <para>This method only works on ObjectListViews and FastObjectListViews.</para> ///</remarks> public virtual void InsertObjects(int index, ICollection modelObjects) { if (this.InvokeRequired) { this.Invoke((MethodInvoker)delegate() { this.InsertObjects(index, modelObjects); }); return; } if (modelObjects == null) return; this.BeginUpdate(); try { // Give the world a chance to cancel or change the added objects ItemsAddingEventArgs args = new ItemsAddingEventArgs(modelObjects); this.OnItemsAdding(args); if (args.Canceled) return; modelObjects = args.ObjectsToAdd; this.TakeOwnershipOfObjects(); ArrayList ourObjects = ObjectListView.EnumerableToArray(this.Objects, false); // If we are filtering the list, there is no way to efficiently // insert the objects, so just put them into our collection and rebuild. if (this.IsFiltering) { ourObjects.InsertRange(index, modelObjects); this.BuildList(true); return; } this.ListViewItemSorter = null; index = Math.Max(0, Math.Min(index, this.GetItemCount())); int i = index; foreach (object modelObject in modelObjects) { if (modelObject != null) { ourObjects.Insert(i, modelObject); OLVListItem lvi = new OLVListItem(modelObject); this.FillInValues(lvi, modelObject); this.Items.Insert(i, lvi); i++; } } for (i = index; i < this.GetItemCount(); i++) { OLVListItem lvi = this.GetItem(i); this.SetSubItemImages(lvi.Index, lvi); } // Tell the world that the list has changed this.OnItemsChanged(new ItemsChangedEventArgs()); } finally { this.EndUpdate(); } }
/// <summary> /// /// </summary> /// <param name="e"></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 (this.VirtualListDataSource == null) return; // Give the world a chance to cancel or change the added objects ItemsAddingEventArgs args = new ItemsAddingEventArgs(modelObjects); this.OnItemsAdding(args); if (args.Canceled) return; try { this.BeginUpdate(); this.VirtualListDataSource.AddObjects(args.ObjectsToAdd); this.BuildList(); } finally { this.EndUpdate(); } }
/// <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 (this.VirtualListDataSource == null) return; // Give the world a chance to cancel or change the added objects ItemsAddingEventArgs args = new ItemsAddingEventArgs(modelObjects); this.OnItemsAdding(args); if (args.Canceled) return; this.ClearCachedInfo(); this.VirtualListDataSource.AddObjects(args.ObjectsToAdd); this.Sort(); this.UpdateVirtualListSize(); }