New to Telerik UI for WinFormsStart a free 30-day trial

Create Custom RichTextEditorRibbonBar

Updated over 6 months ago

This topic explains how one can create custom class that inherits RichTextEditorRibbonBar. This is useful because all events in this class can be overridden. All elements that you see in the ribbon are accessible by their names in the inherited class as well. This allows you to easily modify them from the inherited class.

A common scenario is to hide the "Save As" button and override the functionality of the save button. The following spinet demonstrates this:

Create custom RichTextEditorRibbonBar class

C#
class CustomRichTextEditorRibbonBar : RichTextEditorRibbonBar
{
    public CustomRichTextEditorRibbonBar()
    {
        buttonSaveHTML.Visible = false;
        buttonSavePDF.Visible = false;
        buttonSavePlain.Visible = false;
        buttonSaveRich.Visible = false;
        buttonSaveWord.Visible = false;
        buttonXAML.Visible = false;
        backstageTabItemSaveAs.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
    }
    protected override void ButtonSave_Click(object sender, EventArgs e)
    {
        var provider = new HtmlFormatProvider();
        string content = provider.Export(this.AssociatedRichTextEditor.Document); 
        //save the content to the database for example
    }
}
DefaultCustom
WinForms RadRichTextEditor Default RibbonBarWinForms RadRichTextEditor Custom RibbonBar

See Also

In this article
See Also
Not finding the help you need?
Contact Support