void _selected_ItemAdded(object sender, ListEventArgs <ListBoxItem> e) { if (e.Item == null) { return; } skipEvents = true; e.Item.Selected = true; skipEvents = false; if (SelectedItemsChanged != null) { SelectedItemsChanged(this); } }
// // Summary: // Removes the first occurrence of a specific object from the System.Collections.Generic.ICollection<T>. // // Parameters: // item: // The object to remove from the System.Collections.Generic.ICollection<T>. // // Returns: // true if item was successfully removed from the System.Collections.Generic.ICollection<T>; // otherwise, false. This method also returns false if item is not found in // the original System.Collections.Generic.ICollection<T>. // // Exceptions: // System.NotSupportedException: // The System.Collections.Generic.ICollection<T> is read-only. public new bool Remove(T item) { ListEventArgs <T> args = new ListEventArgs <T>(item); OnBeforeItemRemoved(this, args); if (!args.Cancel) { bool happened = base.Remove(item); if (happened) { OnItemRemoved(this, args); } return(happened); } args = null; return(false); }
void Items_BeforeItemAdded(object sender, ListEventArgs <Control> e) { // item is Null or item is our parent if (e.Item == null || e.Item == Parent) { e.Cancel = true; return; } // we already own this item if (e.Item.Parent == Parent) { e.Cancel = true; return; } if (e.Item.Container != null) { if (!e.Item.Container.Controls.Remove(e.Item)) { e.Cancel = true; return; } } e.Item._isElement = false; if (IsLocked) { e.Cancel = true; toAdd.Add(e.Item); dirtyAdd = true; return; } e.Item.IsRemoved = false; e.Item.ParentControl = Parent; }
void Items_ItemAdded(object sender, ListEventArgs <ListBoxItem> e) { ItemContainer.Controls.Clear(); if (e.Item.Selected) { if (Multiselect) { _selected.Add(e.Item); } else { SelectedItem = e.Item; } } e.Item.MouseClick += item_MouseClick; e.Item.SelectedChanged += Item_SelectedChanged; foreach (ListBoxItem item in Items) { ItemContainer.Controls.Add(item); } }
void TabPages_ItemRemoved(object sender, ListEventArgs <TabPage> e) { e.Item.Button.MouseClick -= Button_MouseClick; e.Item.Button.Parent = null; }
void Controls_ItemAdded(object sender, ListEventArgs <Control> e) { Refresh(); }
private void Controls_ItemRemoved(object sender, ListEventArgs <Control> e) { Refresh(); }