[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
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [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
    AutoCorrect
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
   [Expand]Visual Elements
    Services
    Events
    Commands
    HTML Tag Support
   [Expand]Examples
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [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
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[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)

Commands

Any user action performed with the RichEdit control results in a command object being created and executed. All commands implemented in the Rich Edit control inherit from the Command object. Virtually every task can be accomplished via commands, such as inserting characters and pictures, selection, formatting, creating numbered lists, scrolling, etc.

The command's main method is Command.Execute. It accomplishes the task for which the command is implemented. Other properties, such as Command.Image, Command.LargeImage, Command.Description and Command.MenuCaption are used to visually and verbally represent a command. The following table shows the ToggleFontSuperscriptCommand command properties as an example.

Large image Small image Menu caption Description
Insert Rows Above Add a new row directly above the selected row

If the command is disabled for any reason, you can still use its Command.ForceExecute method to execute it.

A command may require additional data for its execution. Usually they are provided by the ICommandUIState.EditValue property.

You can modify the default functionality of virtually any command by substituting the RichEditCommandFactoryService, available via the IRichEditCommandFactoryService interface. See the IRichEditCommandFactoryService.CreateCommand topic for more information.

Most commands can be executed via keyboard shortcuts recognized by the RichEditControl. You can use the RichEditControl.RemoveShortcutKey and the RichEditControl.AssignShortcutKeyToCommand methods to modify shortcut keys assigned to commands.

You can use commands to replicate user activity on another RichEdit control, even on a different platform.

Note

You should always create a new instance of a command before execution, otherwise you may experience undesired effects and unhandled exceptions.

Note

Commands executed via the Bar (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.

Expanded See Also

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