OnItemRemoved() protected method

protected OnItemRemoved ( System.Windows.Forms.ToolStripItemEventArgs e ) : void
e System.Windows.Forms.ToolStripItemEventArgs
return void
Example #1
0
        private void OnAfterRemove(ToolStripItem item)
        {
            if (_itemsCollection)
            {
                ToolStrip parent = null;
                if (item != null)
                {
                    parent = item.ParentInternal;
                    item.SetOwner(null);
                }

                if (_owner != null)
                {
                    _owner.OnItemRemovedInternal(item);

                    if (!_owner.IsDisposingItems)
                    {
                        ToolStripItemEventArgs e = new ToolStripItemEventArgs(item);
                        _owner.OnItemRemoved(e);

                        // dont fire the ItemRemoved event for Overflow
                        // it would fire constantly.... instead clear any state if the item
                        // is really being removed from the master collection.
                        if (parent != null && parent != _owner)
                        {
                            parent.OnItemVisibleChanged(e, /*performLayout*/ false);
                        }
                    }
                }
            }
        }
Example #2
0
        public void Remove(ToolStripItem value)
        {
            if (this.IsReadOnly)
            {
                throw new NotSupportedException("This collection is read-only");
            }

            base.Remove(value);

            if (value != null && internal_created)
            {
                value.InternalOwner = null;
                value.Parent        = null;
            }

            if (internal_created)
            {
                owner.OnItemRemoved(new ToolStripItemEventArgs(value));
            }

            if (owner.Created)
            {
                owner.PerformLayout();
            }
        }