[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
   [Collapse]Fields
    [Collapse]Field Codes
      AUTHOR
      COMMENTS
      CREATEDATE
      DATE
      DOCPROPERTY
      DOCVARIABLE
      HYPERLINK
      IF
      INCLUDEPICTURE
      KEYWORDS
      LASTSAVEDBY
      MERGEFIELD
      NUMPAGES
      PAGE
      PRINTDATE
      REVNUM
      SAVEDATE
      SEQ
      SUBJECT
      SYMBOL
      TC
      TIME
      TITLE
      TOC
    [Expand]Format Switches
    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]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)

DOCVARIABLE

DOCVARIABLE

Mixed field

{ DOCVARIABLE "variable name" "argument1" "argument 2"... }

Inserts a string associated with a document variable.

The following members are used to obtain a DOCVARIABLE field value.

Expanded Overview

Member Description
Document.Variables DXRichEdit first searches this collection for a specified variable.
Document.CalculateDocumentVariable If variable is not found in the collection, the control raises this event so you can specify the value in code.

Expanded Example: How to Handle the CalculateDocumentVariable event to insert dynamic content

This code snippet demonstrates how to handle the RichEditControl.CalculateDocumentVariable event to insert dynamic content into the document. In this example, it is used to get weather report or geo coordinates from Google web service. A variable name specified in the DOCVARIABLE field indicates a choice between location and weather, while the location itself is specified by the field argument.

Note

Set the event arguments' CalculateDocumentVariableEventArgs.Value property to the DocVariableValue.Current value in the <b>CalculateDocumentVariable</b> event handler to save the initial DOCVARIABLE field value.

Use the FieldOptions.UpdateDocVariablesBeforeCopy, Document.UpdateDocVariablesBeforePrint or the FieldOptions.UpdateDocVariablesBeforePrint properties to specify whether to update the DOCVARIABLE fields before printing or copying a range to the clipboard.

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