Skip to main content

Rich Edit Control

  • 5 minutes to read

The ExpressRichEdit Control (Rich Edit Control for short) is a control intended to aid you in creating fully featured text applications with advanced formatting and display capabilities you expect from a modern word processor.

VCL Rich Edit Control: A Rich Edit Control-Based Demo

The Rich Edit Control (implemented by the TdxRichEditControl component) enables your users to create or edit rich text documents with ease, using a set of commands that provide access to numerous text formatting options and built-in customization dialogs. TAction objects (also called actions) implement these commands programmatically. You can create a powerful word processor in your application by linking these objects to elements of your UI, such as ribbons, menus, and toolbars.

Exposing and Utilizing Supported Actions

Do the following to utilize actions provided by the Rich Edit control:

  1. Add the standard VCL TActionList component from the Component Palette onto a form or select any existing action list. This list stores the Rich Edit Control actions to be used in your application.

  2. Each Rich Edit Control action is associated with an image. Add the TcxImageList component from the Component Palette onto the form and link both the lists using the action list’s Images property to store action images.

  3. Double-click the action list to invoke its Editor. Invoke the Editor’s context menu and click New Standard Action… to display the Standard Action Classes list. Rich Edit Control action classes are registered under the category with the corresponding name.

VCL Rich Edit Control: The Action List Editor

  1. Select one or more action classes and click OK to add respective actions and associated action images to the action and image lists.

  2. Now you can link your UI elements (toolbar items, menu items, buttons, etc.) to the created actions using the element Action property. For instance, to link bar items provided by the ExpressBars Suite to the actions, use a bar item’s Action property. Also, link a bar manager’s ImageOptions.Images property to the image list to display images within bar items.

After that, the Rich Edit Control located on the form responds to executing its actions, and updates their states accordingly.

Alternatively, you may want to employ the automatic design-time UI generation feature.

Supported File Formats

With the current Rich Edit Control version, you can load and save documents from/to DOCX (Office OpenXML), DOC (Microsoft Word® binary format), RTF, HTML, and TXT (plain text) format files.

Text Formatting Features

  • Character and paragraph formatting. Characters can be formatted using different settings for font, font size, character style – bold, italics, underlined, strike-through style, and different colors for the background and foreground. Formatting options for paragraphs include alignment, indentation, adjustable paragraph and line spacing. End-users can customize any of these settings using the Font, Paragraph, and Tabs dialogs.

  • Bulleted and numbered lists, including multilevel lists. End-users can create lists using the Bullets and Numbering dialog.

Text Editing Features

  • The Find and Replace dialog allows end-users to search for a specific word or phrase in a document (the Find tab of the dialog) or search for a specific text and automatically replace it with a specified string (the Replace tab of the dialog).

  • Inline images. End-users can embed images inline in all popular formats, including JPEG, JPG, PNG, GIF, BMP, TIF, TIFF, WMF, EMF, and DIB.

  • Unlimited Undo and Redo operations.

Tables

The Rich Edit Control provides support for complex tables, as well as nested ones. End-users can insert tables, rows, and columns, edit a table layout by splitting and merging cells, align cell content, delete cells, columns, and rows. Borders and shading can be applied individually to each cell in a table.

A hyperlink marks a document range as a hot spot. It can be activated by pressing the Enter key or by clicking while holding down the Ctrl key to navigate to a certain location using a link, which opens in a specified frame. When activated, a hyperlink fires the Rich Edit Control’s OnHyperlinkClick event. End-users can insert and edit hyperlinks using the corresponding dialogs.

Mail Merge

Perform a mail merge in a document in two steps:

  • Specify a document data source using the Rich Edit control’s Options.MailMerge.DataSource property.

  • Create a template by inserting DOCVARIABLE field.

Call the MailMerge method to finish a mail merge and publish the document.

When the Rich Edit control has a specified mail merge data source, you can insert data fields into the opened document by using the Insert Merge Field dialog (invoked via the ShowInsertMergeFieldForm command):

VCL Rich Edit Control: An Insert Merge Field Dialog Example

Document Views and Layout

  • Three predefined document Views: Print Layout, Simple, and Draft. Like in Microsoft® Word®, users can freely switch between them while working on a document.

  • Zooming documents In and Out. All text processing features are available at any zoom level.

  • Document sections. Documents can be partitioned into different sections with individual page settings.

  • Multi-column document layout. This functionality allows users to lay out text in multiple columns within a particular section.

  • Line numbering. Users can add line numbers to document margins for certain types of legal documents. Line numbers can run continuously throughout the document or restart on each page/section.

See Also