ComponentFactory.Krypton.Ribbon.KryptonRibbonGroupDesigner.OnDeleteGroup C# (CSharp) Method

OnDeleteGroup() private method

private OnDeleteGroup ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void OnDeleteGroup(object sender, EventArgs e)
        {
            if ((_ribbonGroup != null) &&
                (_ribbonGroup.Ribbon != null) &&
                 _ribbonGroup.RibbonTab.Groups.Contains(_ribbonGroup))
            {
                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonGroup DeleteGroup");

                try
                {
                    // Get access to the Groups property
                    MemberDescriptor propertyGroups = TypeDescriptor.GetProperties(_ribbonGroup.RibbonTab)["Groups"];

                    // Remove the ribbon tab from the ribbon
                    RaiseComponentChanging(null);
                    RaiseComponentChanging(propertyGroups);

                    // Remove the page from the ribbon
                    _ribbonGroup.RibbonTab.Groups.Remove(_ribbonGroup);

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

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