public void RemoveLineAt(int index) { if (_items == null || index < 0 || index >= _items.Length) { return; } if (_items.Length == 1) { _items = null; } else { var tmp = new ListviewItem[_items.Length - 1]; int c = 0; for (int i = 0; i < _items.Length; i++) { if (i != index) { tmp[c++] = _items[i]; } } _items = tmp; } Invalidate(); }
public void RemoveLine(ListviewItem line) { if (_items == null) { return; } for (int i = 0; i < _items.Length; i++) { if (_items[i] == line) { RemoveLineAt(i); return; } } }
public void AddLine(ListviewItem line) { if (_items == null) { _items = new[] { line } } ; else { var tmp = new ListviewItem[_items.Length + 1]; Array.Copy(_items, tmp, _items.Length); tmp[tmp.Length - 1] = line; _items = tmp; } Invalidate(); }
public void AddLines(ListviewItem[] lines) { if (lines == null) { return; } if (_items == null) { _items = lines; } else { var tmp = new ListviewItem[_items.Length + lines.Length]; Array.Copy(_items, tmp, _items.Length); Array.Copy(lines, 0, tmp, _items.Length, lines.Length); _items = tmp; } Invalidate(); }