Example #1
0
 protected virtual void OnRemovingItem(RemoveEventArgs <T> e)
 {
     if (RemovingItem != null)
     {
         RemovingItem(this, e);
     }
 }
Example #2
0
        protected override void RemoveItem(int index)
        {
            //CancelEventArgs eventArgs = new CancelEventArgs(false);
            RemoveEventArgs <T> eventArgs = new RemoveEventArgs <T>(false, Items[index]);

            OnRemovingItem(eventArgs);

            if (!eventArgs.Cancel)
            {
                T item = Items[index];
                PropertyDescriptorCollection propDescs = TypeDescriptor.GetProperties(item);
                foreach (PropertyDescriptor propDesc in propDescs)
                {
                    if (propDesc.SupportsChangeEvents)
                    {
                        propDesc.RemoveValueChanged(item, OnItemChanged);
                    }
                }
                base.RemoveItem(index);
            }
        }