Log In
[Expand]General Information
[Collapse]WinForms Controls
 [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]Map Control
  [Collapse]Rich Text Editor
   [Expand]Getting Started
      Document Model
      Document Layout
      Positions and Ranges
      Inline Pictures
      Document Fields
      Hyperlinks and Bookmarks
      Headers and Footers
      Range Permissions
      Numbered and Bulleted Lists
      Floating Objects (Shapes)
      Text Boxes
      Document Properties
     Supported Document Formats
     Layout API
     Product Class Structure
     Default Keyboard Shortcuts
     Measure Units
     HTML Tag Interpretation
   [Expand]Visual Elements
   [Expand]Member Tables
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [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]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Report Server
[Expand]eXpressApp Framework
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Document Fields

Document fields are placeholders added to a document, providing the mechanism to replace them with corresponding values when the document is rendered for display or print.

A Field is defined by a set of codes that instructs the RichEditControl to insert text and graphics into a document automatically. The RichEditControl processes a field's codes and inserts data in the field. The inserted data is called the field result. The process itself is called a field update.

A collection of fields in the document is accessible via the SubDocument.Fields property. A field consists of a Field.CodeRange, containing codes, and a Field.ResultRange containing field results.

To insert a field in the document, use the FieldCollection.Create method. It has two overloads - you can convert a document range to a field or insert a field with the specified codes into the specified position.

The default Mailings command bar can be used to switch between field display modes. Fields can be shown with their codes, placeholders or results.

The ShowAllFieldCodesCommand command displays field codes for the entire document.

The ShowAllFieldResultsCommand displays placeholders or field results. The RichEditMailMergeOptions.ViewMergedData option determines whether the actual data record specified by the MailMergeOptions.FirstRecordIndex is displayed, or a data placeholder is shown instead.

The following picture illustrates a data placeholder:

If the RichEditMailMergeOptions.ViewMergedData is switched on, actual data is displayed, as illustrated below:

RichEditControl provides options specifying whether the fields are highlighted in the document, and the highlighting color. These options are accessible via the RichEditControlOptionsBase.Fields property of the control's RichEditControlOptions.

To update the field, use the Field.Update method. An end-user can update a particular field using the corresponding command of the context menu. To update all fields in the document, an end-user can switch on the View Merged Data command button. This operation can also be accomplished by executing the ToggleViewMergedDataCommand or the FieldCollection.Update method.

Show Me

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

To use the Mail Merge feature, the RichEditControl provides the RichEditControlOptionsBase.MailMerge options, to set the data source for the control. Then, the Document.MailMerge method is used to accomplish the merge. You can also specify different data sources and particular records to merge in the Document.MailMerge method call. For more information on Mail Merge, refer to the How to: Perform a Mail Merge document.

Expanded See Also

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