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);
                        }
                    }
                }
            }
        }
 private void OnAfterRemove(ToolStripItem item)
 {
     if (this.itemsCollection)
     {
         ToolStrip parentInternal = null;
         if (item != null)
         {
             parentInternal = item.ParentInternal;
             item.SetOwner(null);
         }
         if ((this.owner != null) && !this.owner.IsDisposingItems)
         {
             ToolStripItemEventArgs e = new ToolStripItemEventArgs(item);
             this.owner.OnItemRemoved(e);
             if ((parentInternal != null) && (parentInternal != this.owner))
             {
                 parentInternal.OnItemVisibleChanged(e, false);
             }
         }
     }
 }