private void OnDeleteTab(object sender, EventArgs e)
{
if ((_ribbonTab != null) &&
(_ribbonTab.Ribbon != null) &&
_ribbonTab.Ribbon.RibbonTabs.Contains(_ribbonTab))
{
// Use a transaction to support undo/redo actions
DesignerTransaction transaction = _designerHost.CreateTransaction("KryptonRibbonTab DeleteTab");
try
{
// Get access to the RibbonTabs property
MemberDescriptor propertyTabs = TypeDescriptor.GetProperties(_ribbonTab.Ribbon)["RibbonTabs"];
// Remove the ribbon tab from the ribbon
RaiseComponentChanging(null);
RaiseComponentChanging(propertyTabs);
// Remove the page from the ribbon
_ribbonTab.Ribbon.RibbonTabs.Remove(_ribbonTab);
// Get designer to destroy it
_designerHost.DestroyComponent(_ribbonTab);
RaiseComponentChanged(propertyTabs, null, null);
RaiseComponentChanged(null, null, null);
}
finally
{
// If we managed to create the transaction, then do it
if (transaction != null)
transaction.Commit();
}
}
}