[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
  Prerequisites
 [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]Gantt Control
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Expand]RichEditControl Document
   [Expand]Fields
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Printing
    Hyphenation
    Spell Checking
    AutoCorrect Feature
    Track Changes
    Mail Merge
    Restrictions and Protection
   [Expand]Visual Elements
    Services
    Events
    Commands
    Keyboard Shortcuts
    HTML Tag Support
   [Collapse]Examples
    [Collapse]Files
      How to: Create a New Document with the RichEdit Control
      How to: Load a Document into the RichEditControl
      How to: Save a Document in the RichEdit Control
    [Expand]Text
    [Expand]Formatting
    [Expand]Styles
    [Expand]Pictures
    [Expand]Tables
    [Expand]Layout
    [Expand]Automation
    [Expand]Search and Replace
    [Expand]Spell Check
    [Expand]Import and Export
    [Expand]Printing
    [Expand]Protection
    [Expand]UI Customization
    [Expand]Commands
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [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]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Load a Document into the RichEditControl

RichEditControl allows you to load a document from a file a data stream or a string Handle one of the related events to determine the moment when the document can be modified.

Expanded Load a Document from a File

Expanded Load a Document from a Stream

The format of the document loaded from a stream is detected automatically by the built-in IFormatDetectorService service implementation. The following formats are detected:

  • DOC, DOCX, RTF, HTM, HTML, MHT, XML, EPUB;
  • ODT - non-encrypted files only;

Use the LoadDocument method overloads with explicit format definition to improve performance.

Expanded Load a Document from a String

This code snippet uses the RichEditControl.RtfText property to load a document from a string in RTF format. It displays the word "Test" in blue.

Expanded Related Events

Events related to document loading are listed in the following table:

Event Description
RichEditControl.BeforeImport Occurs before a document is loaded (imported from an external source).
RichEditControl.InitializeDocument Occurs before a document is loaded. Handle this event to set initial document settings.
RichEditControl.DocumentLoaded Occurs after a document is loaded into the RichEdit control.
DocumentLayout.DocumentFormatted Fires after the document layout is calculated.
RichEditControl.InvalidFormatException Fires when the supplied data could not be recognized as data in the assumed format for import.
RichEditControl.UnhandledException This event is raised when an unhandled exception of the RichEditControl occurs.
Tip

Use RichEditControl Event Viewer application to explore events in detail.

Expanded See Also

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