[Expand]General Information
[Collapse]WinForms Controls
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Expand]RichEditControl Document
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Spell Checking
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
   [Expand]Visual Elements
    Keyboard Shortcuts
    HTML Tag Support
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Text Formatting

RichEditControl provides two ways to format document text.

  • Direct Formatting
    Allows you to change individual formatting attributes for a given range.

  • Document Styles
    Styles can change multiple attributes at the same time. Styles created in code are automatically available to end-users. If you change the style settings, all linked document fragments will be updated automatically.

Both approaches described above are available in API and in the User Interface.

Expanded Direct Formatting

To set the default character and paragraph formatting for a loaded or newly created document, use the following properties.

The code snippet below illustrates how to apply default formatting to a loaded document.

To modify the document title as shown in the image below, use both character and paragraph formatting.

Format Characters

The following members allow you to change character formatting for a given range.

Member Description
SubDocument.BeginUpdateCharacters Initiates the update session and provides access to CharacterProperties for the specified range.
CharacterProperties Holds the character formatting options.
SubDocument.EndUpdateCharacters Finalizes the character formatting update.

The code sample below uses this API to modify the text color and the font type.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T456449.

Format Paragraphs

To change the title's alignment, left indent or any other paragraph option, use the following API.

Member Description
SubDocument.BeginUpdateParagraphs Initiates the update session and provides access to the ParagraphProperties for the specified range.
ParagraphProperties Specifies the paragraph formatting properties.
SubDocument.EndUpdateParagraphs Finalizes the character formatting update.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T456449.

Expanded Document Styles

RichEditControl supports the use of two types of document styles: paragraph and character. The character style can be used if only the character options need to be modified. To change both character (a font type, size, color, etc.) and paragraph (alignment, spacing before and after, etc.) attributes as in the current example, use the paragraph style.
The image below demonstrates chapter titles modified using the paragraph style.

By default, RichEditControl doesn't have any predefined document styles. To create a new document style, use the members from the table below.

Member Description
SubDocument.BeginUpdate Opens the document for editing.
Provides access to the CharacterStyleCollection
Provides access to the ParagraphStyleCollection.
Creates a new CharacterStyle object.
Creates a new ParagraphStyle object.
Specifies the base style for the created instance.
Allows you to synchronize the character and paragraph styles to create a linked style.
Adds the created style to the collection.
Paragraph.Style Sets the style to the given paragraph.
CharacterProperties.Style Specifies the style to the given character range.
SubDocument.EndUpdate Finalizes style creation.

The code sample below demonstrates how to create a new paragraph style and apply it to every chapter.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T456449.

If the loaded document already has document styles, they are automatically added to the document's StyleCollection and you can use them as shown in the code snippet below.


To fill the collection of a newly created document with the predefined styles, load an empty document created in Microsoft® Word® using the Document.LoadDocument method in the RichEditControl.EmptyDocumentCreated event handler.

Linked Styles

To format the document annotation, use a linked style. A linked style carries both character and paragraph formatting rules, but applies them according to the target object. If the style is applied to the Paragraph instance, both formatting options will be applied. With the style applied to the DocumentRange instance, only character formatting is used.

The code sample below demonstrates how to synchronize a paragraph and character style to create a linked style.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T456449.

The image below illustrates the result of the code execution.

Expanded Text Formatting In the User Interface

End-users can change the required format settings using the Font and Paragraph groups of the Home ribbon tab.

The Style Gallery allows end-users to preview and apply the desired document style to the selected text fragment.

To learn how to provide the application with the Ribbon Command UI, refer to the How to: Create a Simple Word Processor with a Ribbon UI topic.

Additionally, the Rich Text Editor application is provided with the following dialogs, which allow end-users to set the character and paragraph formatting options and manage the document styles.

You can prevent end-users from formatting the document. As a result, the corresponding ribbon buttons and the context menu items will be disabled or hidden.
The following members allow you to accomplish this task.

Member Description
Allows you to restrict end-users from direct formatting.
Allows you to disable using document styles at runtime.


You can specify the font and forecolor settings on a control level using the RichEditControl.Font and RichEditControl.ForeColor properties. These options are applied under the following conditions:

  • Text has no direct formatting or styles applied.
  • The options are different from the document's default settings.
Set the RichEditBehaviorOptions.FontSource and RichEditBehaviorOptions.ForeColorSource properties to RichEditBaseValueSource.Control to use only RichEditControl.Font and RichEditControl.ForeColor values.

Expanded See Also

Is this topic helpful?​​​​​​​