[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [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
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
   [Expand]Visual Elements
    HTML Tag Support
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[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.

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.

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.




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.


Sets the style to the given paragraph.


Specifies the style to the given character range.


Finalizes style creation.

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

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.

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.





Allows you to restrict end-users from direct formatting.



Allows you to disable using document styles at runtime.

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