protected override void Dispose(bool disposing)
{
if (disposing)
{
if (_ribbonRichTextBox != null)
{
// Must unhook to prevent memory leaks
_ribbonRichTextBox.MouseEnterControl -= new EventHandler(OnMouseEnterControl);
_ribbonRichTextBox.MouseLeaveControl -= new EventHandler(OnMouseLeaveControl);
_ribbonRichTextBox.ViewPaintDelegate = null;
_ribbonRichTextBox.PropertyChanged -= new PropertyChangedEventHandler(OnRichTextBoxPropertyChanged);
_ribbon.ViewRibbonManager.LayoutAfter -= new EventHandler(OnLayoutAction);
_ribbon.ViewRibbonManager.LayoutBefore -= new EventHandler(OnLayoutAction);
// Remove association with definition
_ribbonRichTextBox.RichTextBoxView = null;
_ribbonRichTextBox = null;
}
}
base.Dispose(disposing);
}