In This Topic
NOV Rich Text Editor provides a lot of commands and settings most of which can be shown to the end user in a ribbon interface. There are two ways to create a ribbon associated with a rich text view:
Rich Text View with Ribbon Control
If you are not creating a cross-platform application, the easiest way to create a rich text view with ribbon is to use the Visual Studio designer and drop an NRichTextViewWithRibbonControl from the Visiual Studio toolbox to your form/window. Check out the Text Ribbon Designer topic for more information on how to use the Visual Studio designer to customize the diagram ribbon.
Alternatively, you can use the NRichTextViewWithRibbon class to add a rich text view with ribbon to your form/window programmatically. The example below demonstrates how to create a rich view with a 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, set it as the Content of a WPF window in a WPF application project, or to the ContentView of a Xamarin.Mac window.
Create a rich text view with ribbon |
Copy Code
|
NRichTextViewWithRibbon ribbonUI = new NRichTextViewWithRibbon(); // Create a rich text view with a ribbon
NRichTextView richTextView = ribbonUI.View; // Get the rich text view
// Create a NOV widget host that hosts the rich text view with ribbon
NNovWidgetHost<NWidget> novHost = new NNovWidgetHost<NWidget>(ribbonUI);
|
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 easiest 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, set it as the Content of a WPF window in a WPF application project or to the ContentView of a Xamarin.Mac window.
Create a Rich Text View with Ribbon |
Copy Code
|
NNovWidgetHost<NRichTextViewWithRibbon> novContent = new NNovWidgetHost<NRichTextViewWithRibbon>();
|
Another way to create a ribbon based commanding UI and associate it with a rich text view is:
Create Ribbon UI |
Copy Code
|
NRichTextRibbonBuilder ribbonBuilder = new NRichTextRibbonBuilder();
NWidget uiWidget = ribbonBuilder.CreateUI(richTextView);
|
To rename a ribbon tab or a ribbon group command builder, change it's name property prior to using it for building the ribbon UI. The following piece of code demonstrates how to rename the "Home" tab page and the "Font" ribbon group:
Rename ribbon tab and group |
Copy Code
|
// Rename the "Home" ribbon tab page
NRibbonTabPageBuilder homeTabBuilder = m_RibbonBuilder.TabPageBuilders[NRichTextRibbonBuilder.TabPageHomeName];
homeTabBuilder.Name = "Start";
// Rename the "Font" ribbon group of the "Home" tab page
NRibbonGroupBuilder fontGroupBuilder = homeTabBuilder.RibbonGroupBuilders[NHomeTabPageBuilder.GroupFontName];
fontGroupBuilder.Name = "Text";
|
See Also