How to: Create the RichEditControl with a Ribbon UI
- 3 minutes to read
This tutorial describes how to create a word processing application with the ribbon UI and adjust its appearance.
In this document:
Note
If you prefer watching a video rather than walking through the step-by-step instructions, check the "Getting Started" tutorial on YouTube: DevExpress WinForms: Rich Text Editor.
Create a RichEditControl Application
In Visual Studio menu, click FILE | New | Project… In the invoked New Project dialog, select Windows Forms Application, specify the project name and location, and click OK.
Drop the RichEditControl item from the DX.18.2: Rich Text Editor toolbox tab onto the form.
Click the RichEditControl’s smart tag and select Dock in Parent Container in the invoked RichEditControl Tasks menu to stretch the control to fill the parent form.
Provide a Ribbon UI
Click the RichEditControl’s smart tag once again, and select Create Ribbon in the invoked menu to add a RibbonControl onto the form and automatically position it above the rich text editor’s work area.
Select Create All Tabs in the RichEditControl Tasks menu to add all available ribbon pages at once (or click the required item(s) to add a particular ribbon tab(s) to the form).
You can also generate a RibbonControl at runtime. The code sample below creates a RibbonControl with all RichEditControl-specific tabs. Paste this code to the form constructor or to the Load event handler.
Click the RibbonControl’s smart tag and select Convert Form To RibbonForm in the invoked RibbonControl Tasks menu to convert the application form to a RibbonForm.
A simple word processing application is now ready. Run it and view the result. For example, type and format text, insert pictures and explore the various ribbon items.
Note
Commands executed using the Ribbon user interface can throw unhandled exceptions if a problem occurs. Consider the situation when a document is being saved to a locked or read-only file. To prevent application failure, subscribe to the RichEditControl.UnhandledException event and set the RichEditUnhandledExceptionEventArgs.Handled property to true.
Change the Application’s Appearance
Change the application’s skin
At design time
In code
Invoke the DevExpress Project Settings page and select a desired skin in the Skin Options group.
Call the UserLookAndFeel.Default static object’s UserLookAndFeel.SetSkinStyle method:
Change the RichEditControl’s skin
Use the RichEditControl.LookAndFeel property to access an object specifying the control’s look and feel settings.
Use bitmap or vector icons
The word processing application uses vector icons by default, which ensures that the application is rendered correctly on high-DPI devices.
Set the static WindowsFormsSettings.AllowDefaultSvgImages property to DefaultBoolean.False at the application’s startup to make your application use bitmap icons in the GUI.
static void Main() { DevExpress.XtraEditors.WindowsFormsSettings.AllowDefaultSvgImages = DevExpress.Utils.DefaultBoolean.False; // ... }
The following images illustrate the standard RichEditControl’s ribbon UI with default vector and bitmap icons:
SVG Icons Bitmap Icons - You can disable or hide any command button on a ribbon tab by specifying restriction settings. Set the required properties of the RichEditBehaviorOptions (RichEditControl.Options.Behavior) and DocumentCapabilitiesOptions (RichEditControl.Options.DocumentCapabilities) objects to the DocumentCapability value to solve this task.
Tip
Refer to the Examples section for more examples on how to work with the Rich Text Editor.