public virtual void Clear() { if (IsReadOnly) { throw new NotSupportedException(SR.ToolStripItemCollectionIsReadOnly); } if (Count == 0) { return; } ToolStripOverflow overflow = null; if (_owner != null && !_owner.IsDisposingItems) { _owner.SuspendLayout(); overflow = _owner.GetOverflow(); if (overflow != null) { overflow.SuspendLayout(); } } try { while (Count != 0) { RemoveAt(Count - 1); } } finally { if (overflow != null) { overflow.ResumeLayout(false); } if (_owner != null && !_owner.IsDisposingItems) { _owner.ResumeLayout(); } } }
public virtual void Clear() { if (this.IsReadOnly) { throw new NotSupportedException(System.Windows.Forms.SR.GetString("ToolStripItemCollectionIsReadOnly")); } if (this.Count != 0) { ToolStripOverflow overflow = null; if ((this.owner != null) && !this.owner.IsDisposingItems) { this.owner.SuspendLayout(); overflow = this.owner.GetOverflow(); if (overflow != null) { overflow.SuspendLayout(); } } try { while (this.Count != 0) { this.RemoveAt(this.Count - 1); } } finally { if (overflow != null) { overflow.ResumeLayout(false); } if ((this.owner != null) && !this.owner.IsDisposingItems) { this.owner.ResumeLayout(); } } } }