Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  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]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
   [Expand]Getting Started
   [Expand]RichEditControl Document
   [Expand]Fields
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Printing
    Spell Checking
    AutoCorrect
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
    Traversing the Document
   [Expand]Visual Elements
    Services
    Events
    Commands
   [Expand]Member Tables
    Keyboard Shortcuts
    HTML Tag Interpretation
   [Expand]Examples
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap 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]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

AutoCorrect

The RichEditControl AutoCorrect feature can help you automate inserting frequently used text, auto-correcting typing errors and misspelled capitalization. You can specify the built-in options, construct a custom replacement table or handle the Autocorrect event to analyze the input text and provide the necessary substitution.

Expanded Built-in Automatic Correction Options

The following members enable you to enable certain automatic correction features:

Property Description
AutoCorrectOptions.DetectUrls Automatically detects an inserted web address, a network path or email address and converts it to a hyperlink.
AutoCorrectOptions.CorrectTwoInitialCapitals Corrects capitalization errors.
AutoCorrectOptions.ReplaceTextAsYouType Scans for entries as you type and replaces them with the designated text or image.
AutoCorrectOptions.UseSpellCheckerSuggestions Automatically detects and corrects typos and misspelled word if the RichEditControl.SpellChecker property specifies a spell checker component. If the spell checker provides one suggestion, this suggestion automatically substitutes the incorrect word. Otherwise, no changes are made.

Use the richEditCotnrol.Options.AutoCorrect notation to access the built-in autocorrect options, as shown in the code snippet below:

Show Me

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

Expanded Automatic Correction Using Table Entries

The text expander functionality allows you to insert symbols, decipher abbreviations and insert images. Follow the steps below to implement the text expander:

  1. Create a new AutoCorrectReplaceInfoCollection instance and fill it with AutoCorrectReplaceInfo entries:

    Show Me

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

  2. Call the IAutoCorrectService.SetReplaceTable method to register a created replacement list:

    Show Me

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

  3. When you type a space, punctuation mark or carriage return (a character that typically means you have finished typing a word), AutoCorrect compares the word (or more precisely the group of characters) against its list of entries. If the word matches an entry, AutoCorrect substitutes this word with a replacement object.

    In this example, the substitution is performed as shown in the animation below:

Expanded Automatic Correction Using the AutoCorrect Event

Handle the RichEditControl.AutoCorrect event to analyze the input text and provide a specific object for replacement. Use the following API (accessible using the AutoCorrectEventArgs.AutoCorrectInfo property) to perform the desired actions:

API Description
AutoCorrectInfo.Text Gets the input string to check whether it should be replaced.
AutoCorrectInfo.IncrementStartPosition Decreases a text range being analyzed by moving its start by one position.
AutoCorrectInfo.DecrementStartPosition Extends a text range being analyzed by moving its start by one position.
AutoCorrectInfo.IncrementEndPosition Extends a text range being analyzed by moving its end by one position.
AutoCorrectInfo.DecrementEndPosition Decreases a text range being analyzed by moving its end by one position.
AutoCorrectInfo.ReplaceWith Gets or sets the object used to replace the input string in the document.

Show Me

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

The following code sample shows how to handle the RichEditControl.AutoCorrect event to replace the typed $ symbol with a picture of a dollar, and substitute the text enclosed in percent symbols with custom content.

Use the AutoCorrectEventArgs.AutoCorrectInfo property to obtain the document text, then call the AutoCorrectInfo.DecrementStartPosition method to expand its left boundary until a special symbol or a word separator symbol is found. Use the AutoCorrectInfo.ReplaceWith property to pass a replacement object (a string or an image) to the document if a resulting string meets certain conditions, such as whether it is a dollar sign or a %date% string.

How would you rate this topic?​​​​​​​