public void RemoveItemAt(int index) { if (_items == null || index < 0 || index >= _items.Length) { return; } if (_items.Length == 1) { ClearItems(); return; } //if (_items[index] == _removing) // return; Suspended = true; _items[index].Parent = null; var tmp = new ListboxItem[_items.Length - 1]; int c = 0; for (int i = 0; i < _items.Length; i++) { if (i != index) { tmp[c++] = _items[i]; } } _items = tmp; _recalc = true; Suspended = false; }
public void AddItems(ListboxItem[] items) { if (items == null) { return; } Suspended = true; for (int i = 0; i < items.Length; i++) { items[i].Parent = this; } if (_items == null) { _items = items; } else { var tmp = new ListboxItem[_items.Length + items.Length]; Array.Copy(_items, tmp, _items.Length); Array.Copy(items, 0, tmp, _items.Length, items.Length); _items = tmp; } _recalc = true; Suspended = false; }
/// <summary> /// Adds a number of items to the combo box /// </summary> /// <param name="items">Items to add</param> public void AddItems(ListboxItem[] items) { if (items == null) { return; } Suspended = true; try { //for (int i = 0; i < items.Length; i++) // items[i].Parent = this; if (_items == null) { _items = items; } else { var tmp = new ListboxItem[_items.Length + items.Length]; Array.Copy(_items, tmp, _items.Length); Array.Copy(items, 0, tmp, _items.Length, items.Length); _items = tmp; } if (_selIndex == -1) { _selIndex = 0; } } finally { Suspended = false; } }
public void RemoveItem(ListboxItem item) { if (_items == null) // || item == _removing) { return; } for (int i = 0; i < _items.Length; i++) { if (_items[i] == item) { RemoveItemAt(i); return; } } }
public void AddItem(ListboxItem item) { // Update Array Size if (_items == null) { _items = new[] { item }; } else { var tmp = new ListboxItem[_items.Length + 1]; Array.Copy(_items, tmp, _items.Length); tmp[tmp.Length - 1] = item; _items = tmp; } item.Parent = this; _recalc = true; Invalidate(); }