[Expand]General Information
[Expand]WinForms Controls
[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
[Collapse]Office File API
  Demo Application
  Redistribution and Deployment
 [Expand]Spreadsheet Document API
 [Expand]Word Processing Document API
 [Expand]PDF Document API
 [Expand]Excel Export Library
 [Expand]Snap Report API
 [Expand]Zip Compression and Archive API
 [Expand]Barcode Generation API
 [Expand]Unit Conversion API
 [Collapse]API Reference
  [Expand]DevExpress.BarCodes
  [Expand]DevExpress.Compression
  [Expand]DevExpress.Docs.Text
  [Expand]DevExpress.Office
  [Expand]DevExpress.Office.Drawing
  [Expand]DevExpress.Office.Export
  [Expand]DevExpress.Office.Export.Html
  [Expand]DevExpress.Office.Import
  [Expand]DevExpress.Office.Localization
  [Expand]DevExpress.Office.Options
  [Expand]DevExpress.Office.Services
  [Expand]DevExpress.Office.Utils
  [Expand]DevExpress.Pdf
  [Expand]DevExpress.Pdf.Localization
  [Expand]DevExpress.Snap
  [Expand]DevExpress.Spreadsheet
  [Expand]DevExpress.Spreadsheet.Charts
  [Expand]DevExpress.Spreadsheet.Drawings
  [Expand]DevExpress.Spreadsheet.Export
  [Expand]DevExpress.Spreadsheet.Formulas
  [Expand]DevExpress.Spreadsheet.Functions
  [Expand]DevExpress.UnitConversion
  [Expand]DevExpress.XtraPrinting
  [Expand]DevExpress.XtraPrintingLinks
  [Expand]DevExpress.XtraRichEdit
  [Expand]DevExpress.XtraRichEdit.API.Layout
  [Collapse]DevExpress.XtraRichEdit.API.Native
   [Expand]AbstractNumberingList Interface
   [Expand]AbstractNumberingListCollection Interface
    AutoFitBehaviorType Enumeration
   [Expand]Bookmark Interface
   [Expand]BookmarkCollection Interface
   [Expand]Capture Interface
   [Expand]CaptureCollection Interface
   [Expand]CharacterProperties Interface
   [Expand]CharacterPropertiesBase Interface
    CharacterPropertiesMask Enumeration
   [Expand]CharacterStyle Interface
   [Expand]CharacterStyleCollection Interface
   [Expand]CheckBox Interface
    CheckBoxSizeMode Enumeration
    CheckBoxState Enumeration
   [Expand]Comment Interface
   [Expand]CommentCollection Interface
    CompatibilityMode Enumeration
   [Expand]CompatibilitySettings Interface
    ConditionalTableStyleFormattingTypes Enumeration
   [Expand]CustomMark Interface
   [Expand]CustomMarkCollection Interface
   [Collapse]Document Interface
     Document Members
    [Expand]Document Properties
    [Collapse]Document Events
      CalculateDocumentVariable Event
      ContentChanged Event
      ModifiedChanged Event
    [Expand]Document Methods
   [Expand]DocumentBookmark Class
   [Expand]DocumentBookmarkEnd Class
   [Expand]DocumentBookmarkStart Class
   [Expand]DocumentCheckBox Class
   [Expand]DocumentCommentElement Class
   [Expand]DocumentCommentEnd Class
   [Expand]DocumentCommentStart Class
   [Expand]DocumentCustomProperties Interface
   [Expand]DocumentElementBase Class
    DocumentElementType Enumeration
   [Expand]DocumentEncryption Interface
   [Expand]DocumentFieldCodeEnd Class
   [Expand]DocumentFieldCodeStart Class
   [Expand]DocumentFieldResultEnd Class
   [Expand]DocumentFormFieldBase Class
   [Expand]DocumentHyperlink Class
   [Expand]DocumentHyperlinkEnd Class
   [Expand]DocumentHyperlinkStart Class
   [Expand]DocumentImage Interface
   [Expand]DocumentImageCollection Interface
   [Expand]DocumentImageSource Class
   [Expand]DocumentInlinePicture Class
   [Expand]DocumentIterator Class
   [Expand]DocumentParagraphEnd Class
   [Expand]DocumentParagraphStart Class
   [Expand]DocumentPicture Class
   [Expand]DocumentPosition Class
   [Expand]DocumentProperties Interface
    DocumentProtectionType Enumeration
   [Expand]DocumentRange Interface
   [Expand]DocumentRangePermissionEnd Class
   [Expand]DocumentRangePermissionStart Class
   [Expand]DocumentSectionEnd Class
   [Expand]DocumentSectionStart Class
   [Expand]DocumentTableCellBorder Class
   [Expand]DocumentText Class
   [Expand]DocumentTextBox Class
   [Expand]DocumentVisitorBase Class
   [Expand]EncryptionSettings Class
    EncryptionType Enumeration
   [Expand]Field Interface
   [Expand]FieldCollection Interface
   [Expand]FixedRange Class
   [Expand]FormField Interface
   [Expand]FormFieldCollection Interface
    FormFieldTextType Enumeration
    FormFieldType Enumeration
   [Expand]Group Interface
   [Expand]GroupCollection Interface
    HeaderFooterType Enumeration
    HeightType Enumeration
   [Expand]Hyperlink Interface
   [Expand]HyperlinkCollection Interface
   [Expand]IDocumentElement Interface
   [Expand]IDocumentVisitor Interface
    InsertOptions Enumeration
   [Expand]IRegexSearchResult Interface
   [Expand]ISearchResult Interface
    LineNumberingRestart Enumeration
   [Expand]ListLevel Interface
   [Expand]ListLevelProperties Interface
    MailMergeNumberingRestart Enumeration
   [Expand]MailMergeOptions Interface
   [Expand]Match Interface
   [Expand]MergeFieldName Class
    MergeMode Enumeration
    NumberingFormat Enumeration
   [Expand]NumberingList Interface
   [Expand]NumberingListBase Interface
   [Expand]NumberingListCollection Interface
    NumberingType Enumeration
   [Expand]OverrideListLevel Interface
   [Expand]Paragraph Class
    ParagraphAlignment Enumeration
   [Expand]ParagraphCollection Interface
    ParagraphFirstLineIndent Enumeration
    ParagraphLineSpacing Enumeration
   [Expand]ParagraphProperties Interface
   [Expand]ParagraphPropertiesBase Interface
    ParagraphPropertiesMask Enumeration
   [Expand]ParagraphPropertiesWithTabs Interface
   [Expand]ParagraphStyle Interface
   [Expand]ParagraphStyleCollection Interface
   [Expand]RangePermission Class
   [Expand]RangePermissionCollection Class
   [Expand]ReadOnlyBookmarkCollection Interface
   [Expand]ReadOnlyCheckBoxProperties Interface
   [Expand]ReadOnlyCommentCollection Interface
   [Expand]ReadOnlyCustomMarkCollection Interface
   [Expand]ReadOnlyDocumentImageCollection Interface
   [Expand]ReadOnlyFieldCollection Interface
   [Expand]ReadOnlyFormFieldProperties Interface
   [Expand]ReadOnlyHyperlinkCollection Interface
   [Expand]ReadOnlyParagraphCollection Interface
   [Expand]ReadOnlyParagraphProperties Interface
   [Expand]ReadOnlyParagraphPropertiesBase Interface
   [Expand]ReadOnlyParagraphStyle Interface
   [Expand]ReadOnlySectionLineNumbering Interface
   [Expand]ReadOnlySectionMargins Interface
   [Expand]ReadOnlySectionPage Interface
   [Expand]ReadOnlySectionPageNumbering Interface
   [Expand]ReadOnlySectionsProperties Interface
   [Expand]ReadOnlyShapeCollection Interface
   [Expand]ReadOnlyTableCellBorderProperties Class
   [Expand]ReadOnlyTableCollection Interface
   [Expand]ReadOnlyTextProperties Interface
   [Expand]ReadOnlyTextPropertiesBase Interface
    SearchDirection Enumeration
    SearchOptions Enumeration
   [Expand]Section Interface
   [Expand]SectionCollection Interface
   [Expand]SectionColumn Class
   [Expand]SectionColumnCollection Class
   [Expand]SectionColumns Interface
   [Expand]SectionLineNumbering Interface
   [Expand]SectionMargins Interface
   [Expand]SectionPage Interface
   [Expand]SectionPageNumbering Interface
    SectionStartType Enumeration
   [Expand]SelectionCollection Class
   [Expand]Shape Interface
   [Expand]ShapeCollection Interface
   [Expand]ShapeFill Interface
    ShapeHorizontalAlignment Enumeration
   [Expand]ShapeLine Interface
    ShapeRelativeHorizontalPosition Enumeration
    ShapeRelativeVerticalPosition Enumeration
    ShapeVerticalAlignment Enumeration
    StrikeoutType Enumeration
   [Expand]SubDocument Interface
    SubDocumentType Enumeration
   [Expand]SyntaxHighlightProperties Class
   [Expand]SyntaxHighlightToken Class
    TabAlignmentType Enumeration
   [Expand]TabInfo Class
   [Expand]TabInfoCollection Class
   [Expand]Table Interface
    TabLeaderType Enumeration
   [Expand]TableBorder Interface
    TableBorderLineStyle Enumeration
   [Expand]TableBorders Interface
   [Expand]TableCell Interface
   [Expand]TableCellBorder Interface
   [Expand]TableCellBorders Interface
   [Expand]TableCellCollection Interface
    TableCellProcessorDelegate Delegate
   [Expand]TableCellPropertiesBase Interface
    TableCellPropertiesMask Enumeration
   [Expand]TableCellStyle Interface
   [Expand]TableCellStyleCollection Interface
    TableCellVerticalAlignment Enumeration
   [Expand]TableCollection Interface
   [Expand]TableConditionalStyle Interface
   [Expand]TableConditionalStyleProperties Interface
    TableLayoutType Enumeration
    TableLookTypes Enumeration
   [Expand]TablePropertiesBase Interface
    TablePropertiesMask Enumeration
   [Expand]TableRow Interface
    TableRowAlignment Enumeration
   [Expand]TableRowCollection Interface
    TableRowProcessorDelegate Delegate
   [Expand]TableStyle Interface
   [Expand]TableStyleCollection Interface
   [Expand]TemplateAbstractNumberingList Interface
   [Expand]TextBox Interface
    TextBoxSizeRule Enumeration
    TextWrappingSide Enumeration
    TextWrappingType Enumeration
    UnderlineType Enumeration
    VerticalMergingState Enumeration
    WidthType Enumeration
  [Expand]DevExpress.XtraRichEdit.API.Native.Implementation
  [Expand]DevExpress.XtraRichEdit.Commands
  [Expand]DevExpress.XtraRichEdit.Export
  [Expand]DevExpress.XtraRichEdit.Export.Html
  [Expand]DevExpress.XtraRichEdit.Export.PlainText
  [Expand]DevExpress.XtraRichEdit.Export.Rtf
  [Expand]DevExpress.XtraRichEdit.Forms
  [Expand]DevExpress.XtraRichEdit.Import
  [Expand]DevExpress.XtraRichEdit.Localization
  [Expand]DevExpress.XtraRichEdit.Services
  [Expand]DevExpress.XtraRichEdit.Utils
  [Expand]DevExpress.XtraSpreadsheet
  [Expand]DevExpress.XtraSpreadsheet.Export
  [Expand]DevExpress.XtraSpreadsheet.Export.Html
  [Expand]DevExpress.XtraSpreadsheet.Import
  [Expand]DevExpress.XtraSpreadsheet.Localization
  [Expand]DevExpress.XtraSpreadsheet.Services
[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)

Document.CalculateDocumentVariable Event

Fires when the DOCVARIABLE field is updated.

Namespace:DevExpress.XtraRichEdit.API.Native
Assembly:DevExpress.RichEdit.v19.1.Core.dll

Expanded Syntax

Expanded Event Data

The event handler receives an argument of type CalculateDocumentVariableEventArgs containing data related to this event.

The following CalculateDocumentVariableEventArgs properties provide information specific to this event.
Property Description
Arguments Provides access to a collection of arguments within the DOCVARIABLE field.
FieldLocked Gets or sets a locked attribute to the field for which the event occurs.
Handled Gets or sets whether the default action is required.
KeepLastParagraph Gets or sets whether the last paragraph of the inserted document is kept in the resulting document.
PreserveInsertedContentFormatting Gets or sets whether to insert an additional hidden paragraph so that the inserted content is not formatted with the DOCVARIABLE field's paragraph formatting.
Value Gets or sets the value of the DOCVARIABLE field that fired the event.
VariableName Gets the name of the document variable to which the DOCVARIABLE field refers.

Expanded Remarks

The CalculateDocumentVariable event is fired when the DOCVARIABLE value is calculated. The event is fired when a field is updated (using UI commands, Field.Update or FieldCollection.Update methods), or during the Mail Merge on the DevExpress.XtraRichEdit.RichEditControl.MailMerge method call. Handle this event to analyze DOCVARIABLE field switches and arguments, and provide custom content to insert into this field.

Assign a special DocVariableValue.Current value to the CalculateDocumentVariableEventArgs.Value property and set e.Handled to true to retain the existing DOCVARIABLE value.

You can specify the FieldOptions.UpdateLockedFields property to raise the event for locked DOCVARIABLE fields.

You can lock/unlock the field within the CalculateDocumentVariable handler using the CalculateDocumentVariableEventArgs.FieldLocked property. Set e.Handled to true to apply changes.

Expanded Example

Note

A complete code sample project is available at How to use document variable (DOCVARIABLE) fields.

This code snippet demonstrates how to handle the 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 indicates a choice between location and weather, while the location itself is specified by the field argument.

Expanded See Also

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