/// <summary> /// Removes the specified collection of items from the collection. /// </summary> /// <param name="item">A <see cref="TreeListViewItemCollection"/> to remove from the collection.</param> public void RemoveRange(TreeListViewItemCollection items) { if (items == null) { return; } // Aulofee customization - start. Line below added. _listView.BeginUpdate(); TreeListViewItem recalculateFrom = null; for (int i = items.Count - 1; i >= 0; i--) { TreeListViewItem newRecalculateFrom = RemoveInternal(items[i]); if (recalculateFrom == null || newRecalculateFrom.Y < recalculateFrom.Y) { recalculateFrom = newRecalculateFrom; } } _listView.RecalculateItemPositions(recalculateFrom); // Aulofee customization - start. Line below added. _listView.EndUpdate(); }
private int AutoSizeItems(TreeListViewItemCollection items) { int colIndex = this.Index; int colDisplayIndex = this.DisplayIndex; int twid = 0; int mwid = 0; int baseIndent = 0; if (colDisplayIndex == 0) { if (ListView.ShowPlusMinus || (ListView.ShowTreeLines && ListView.ShowRootTreeLines)) { baseIndent += 16; } } for (int index = 0; index < items.Count; ++index) { twid = 0; TreeListViewItem item = items[index]; Font fnt = item.Font; if (fnt == null) { fnt = Font; } if (item.ImageIndex > -1 || item.SelectedImageIndex > -1) { twid += 16; } if (colDisplayIndex == 0) { twid += baseIndent + (16 * (item.Depth - 1)); } twid += GetStringWidth(item.SubItems[colIndex].Text, fnt) + 10; twid += 5; if (twid > mwid) { mwid = twid; } if (item.HasChildren && item.Expanded) { twid = AutoSizeItems(item.Items); if (twid > mwid) { mwid = twid; } } } return(mwid); }