Nevron Open Vision Documentation
Rich Text Ribbon Builder

NOV Text Editor provides a ribbon builder that can be used to create and associate ribbon commanding UI to a rich text view. The builder is represented by the NRichTextRibbonBuilder class. The following code fragment demonstrates how to create a ribbon based commanding UI and associate it with a rich text view:

Create Ribbon UI
Copy Code
NRichTextRibbonBuilder ribbonBuilder = new NRichTextRibbonBuilder();
NWidget uiWidget = ribbonBuilder.CreateUI(richTextView);

Another way to create a rich text view with ribbon is to use the NRichTextViewViewWithRibbon class. The example below demonstrates how to create a rich text view with ribbon hosted in a NOV widget host. You can then add this host to a form's Controls collection if you are creating a WinForms application or set it as the content of a WPF window in a WPF application project.

Create a Rich Text View with Ribbon
Copy Code
NNovWidgetHost<NRichTextViewWithRibbon> novContent = new NNovWidgetHost<NRichTextViewWithRibbon>();
Modifying Ribbon Group Builders Collection

If you want to remove a given ribbon tab page, you can easily do so by using the Remove method of the TabPageBuilders collection of the rich text ribbon builder. To remove a ribbon group from a tab page, you should use the Remove method of the RibbonGroupBuilders collection of the ribbon group builder.

The names of all rich text ribbon tab pages are exposed as constants in the NRichTextRibbonBuilder class. Each of the tab page builders exposes as constants the names of its ribbon group builders. The following piece of code demonstrates how to remove the "Clipboard" ribbon group of the "Home" tab page of the rich text ribbon:

Remove ribbon group
Copy Code
NRibbonTabPageBuilder homeTabBuilder = ribbonBuilder.TabPageBuilders[NRichTextRibbonBuilder.TabPageHomeName];

In order to add or insert your own ribbon group builders, you can use the Add or Insert methods of the RibbonGroupBuilders collection respectively.

Add custom ribbon group
Copy Code
NRibbonTabPageBuilder homeTabBuilder = ribbonBuilder.TabPageBuilders[NRichTextRibbonBuilder.TabPageHomeName];
homeTabBuilder.RibbonGroupBuilders.Insert(0, new CustomRibbonGroupBuilder());
Custom Ribbon Group Builders

To create a custom ribbon group builder you should create a class, which inherits NRibbonGroupBuilder:

Custom ribbon group builder
Copy Code
public class CustomRibbonGroupBuilder : NRibbonGroupBuilder
    public CustomRibbonGroupBuilder()
        : base("Custom Group", NResources.Image_Ribbon_16x16_smiley_png)

    protected override void AddRibbonGroupItems(NRibbonGroupItemCollection items)
        // Add the "Copy" command
            Nevron.Nov.Presentation.NResources.Image_Edit_Copy_png, NRichTextView.CopyCommand));

        // Add the custom command
        items.Add(CreateRibbonButton(NResources.Image_Ribbon_32x32_smiley_png, NResources.Image_Ribbon_16x16_smiley_png, CustomCommand));
See Also


Send Feedback