ComponentFactory.Krypton.Ribbon.KryptonRibbonGroupDomainUpDownDesigner.OnDeleteDomainUpDown C# (CSharp) Method

OnDeleteDomainUpDown() private method

private OnDeleteDomainUpDown ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void OnDeleteDomainUpDown(object sender, EventArgs e)
        {
            if ((_ribbonDomainUpDown != null) && (_ribbonDomainUpDown.Ribbon != null))
            {
                // Get access to the parent collection of items
                TypedRestrictCollection<KryptonRibbonGroupItem> items = ParentItems;

                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroupDomainUpDown DeleteDomainUpDown");

                try
                {
                    // Get access to the Items property
                    MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonDomainUpDown.RibbonContainer)["Items"];

                    RaiseComponentChanging(null);
                    RaiseComponentChanging(propertyItems);

                    // Remove the numeric up-down from the group
                    items.Remove(_ribbonDomainUpDown);

                    // Get designer to destroy it
                    _designerHost.DestroyComponent(_ribbonDomainUpDown);

                    RaiseComponentChanged(propertyItems, null, null);
                    RaiseComponentChanged(null, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    if (transaction != null)
                        transaction.Commit();
                }
            }
        }