Ejemplo n.º 1
0
        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();
                }
            }
        }