private void OnDeleteDateTimePicker(object sender, EventArgs e)
{
if ((_ribbonDateTimePicker != null) && (_ribbonDateTimePicker.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("KryptonRibbonGroupDateTimePicker DeleteDateTimePicker");
try
{
// Get access to the Items property
MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonDateTimePicker.RibbonContainer)["Items"];
RaiseComponentChanging(null);
RaiseComponentChanging(propertyItems);
// Remove the date time picker from the group
items.Remove(_ribbonDateTimePicker);
// Get designer to destroy it
_designerHost.DestroyComponent(_ribbonDateTimePicker);
RaiseComponentChanged(propertyItems, null, null);
RaiseComponentChanged(null, null, null);
}
finally
{
// If we managed to create the transaction, then do it
if (transaction != null)
transaction.Commit();
}
}
}