[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]Property 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
    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
    Spell Checking
    AutoCorrect
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
   [Expand]Visual Elements
    Services
    Events
    Commands
    Keyboard Shortcuts
    HTML Tag Support
   [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]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

DOCVARIABLE

DOCVARIABLE

Mixed field

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

Expanded Overview

Inserts a string associated with a document variable.

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

Member Description
Document.Variables RichEditControl 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: Handle the CalculateDocumentVariable Event to Insert Dynamic Content.

Show Me

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

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 conditions. 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 CalculateDocumentVariable 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.

Expanded See Also

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