internal void InternalInsert(int index, TreeListViewSubItem subItem) { lock (_data.SyncRoot) { _data.Insert(index, subItem); subItem.Collection = this; } }
/// <summary> /// Inserts an existing <see cref="TreeListViewSubItem"/> object to the collection at the specified index. /// </summary> /// <param name="index">The zero-based index location where the item is inserted.</param> /// <param name="subItem">The <b>TreeListViewSubItem</b> object to add to the collection.</param> public void Insert(int index, TreeListViewSubItem subItem) { if (_owningItem.ListView != null) { throw new NotSupportedException("Cannot modify sub item collection while the item is attached to a list."); } InternalInsert(index, subItem); }
public void Refresh(TreeListViewSubItem subItem) { if (_updateSuspended || _listView == null || !_listView.IsVisible(this)) { return; } _listView.Refresh(subItem); }
/// <summary> /// Adds an existing <see cref="TreeListViewSubItem"/> object to the collection. /// </summary> /// <param name="subItem">The <b>TreeListViewSubItem</b> object to add to the collection.</param> /// <returns>The position into which the new element was inserted.</returns> public int Add(TreeListViewSubItem subItem) { if (_owningItem.ListView != null) { throw new NotSupportedException("Cannot modify sub item collection while the item is attached to a list."); } int index = _data.Count; InternalInsert(index, subItem); return(index); }
/// <summary> /// Creates a close clone of this sub-item that is unattached to any item. /// Since a control cannot exist in two places at once, it does not copy /// the ItemControl property. /// </summary> /// <returns></returns> public TreeListViewSubItem Clone() { TreeListViewSubItem slvi = new TreeListViewSubItem(this._columnIndex); slvi._backColor = _backColor; slvi._childControlInitialSize = _childControlInitialSize; slvi._controlResizeBehavior = _controlResizeBehavior; slvi._font = _font; slvi._foreColor = _foreColor; slvi._tag = _tag; slvi._object = _object; slvi._toolTip = _toolTip; return(slvi); }
/// <summary> /// Removes an item from the collection at the specified index. /// </summary> /// <param name="index">The zero-based index position of the item that is to be removed.</param> public void RemoveAt(int index) { if (_owningItem.ListView != null) { throw new NotSupportedException("Cannot modify a sub item collection while the item is attached to a list."); } TreeListViewSubItem subItem = this[index]; lock (_data.SyncRoot) { _data.RemoveAt(index); subItem.Collection = null; if (subItem.ItemControl != null) { subItem.ItemControl.Visible = false; } } }
/// <summary> /// Removes the specified <see cref="TreeListViewItem"/> from the collection. /// </summary> /// <param name="subItem">A <see cref="TreeListViewSubItem"/> to remove from the collection.</param> public void Remove(TreeListViewSubItem subItem) { if (subItem == null) { return; } if (_owningItem.ListView != null) { throw new NotSupportedException("Cannot modify sub item collection while the item is attached to a list."); } lock (_data.SyncRoot) { _data.Remove(subItem); subItem.Collection = null; if (subItem.ItemControl != null) { subItem.ItemControl.Visible = false; } } }
/// <summary> /// Compares the two incoming <see cref="TreeListViewItem"/> elements. /// </summary> /// <param name="item1">The first item to compare.</param> /// <param name="item2">The second item to compare.</param> /// <returns>Zero if equal, -1 if item1 < item2, 1 if item1 > item2</returns> public int Compare(TreeListViewItem item1, TreeListViewItem item2) { for (int index = 0; index < _sortColumns.Length; ++index) { // cache these values so as to make all of this a little bit faster TreeListViewColumnHeader sortColumn = _sortColumns[index]; int sortColumnIndex = _sortColumnIndices[index]; SortOrder sortOrder = sortColumn.SortOrder; SortDataType sortDataType = sortColumn.SortDataType; if (item1 == null || item2 == null || sortOrder == SortOrder.None || sortDataType == SortDataType.None) { return(0); // We don't know type, the order, or the data - so both objects are same for us } int n = 0; TreeListViewSubItem subItem1 = sortOrder == SortOrder.Ascending ? item1.SubItems[sortColumnIndex] : item2.SubItems[sortColumnIndex]; TreeListViewSubItem subItem2 = sortOrder == SortOrder.Ascending ? item2.SubItems[sortColumnIndex] : item1.SubItems[sortColumnIndex]; if (sortDataType == SortDataType.Custom) { n = sortColumn.CustomSortComparer.Compare(subItem1, subItem2); } else { n = CompareItems(subItem1.Text, subItem2.Text, sortDataType); } if (n != 0) { return(n); } } return(0); }
/// <summary> /// Determines whether the specified item is located in the collection. /// </summary> /// <param name="item">A <see cref="TreeListViewSubItem"/> representing the item to locate in the collection.</param> /// <returns><b>true</b> if the column is contained in the collection; otherwise, <b>false</b>.</returns> public bool Contains(TreeListViewSubItem item) { return(_data.Contains(item)); }
/// <summary> /// Returns the index within the collection of the specified sub item. /// </summary> /// <param name="item">A <see cref="TreeListViewSubItem"/> representing the item to locate in the collection.</param> /// <returns>The zero-based index of the item's location in the collection. If the item is not located in the collection the return value is negative one (-1).</returns> public int IndexOf(TreeListViewSubItem item) { return(_data.IndexOf(item)); }