[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
 [Expand]Controls and Libraries
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Collapse]API Reference
  [Expand]DevExpress.Charts.Designer
  [Expand]DevExpress.Data
  [Expand]DevExpress.Mvvm.UI
  [Expand]DevExpress.Mvvm.UI.Interactivity
  [Expand]DevExpress.Mvvm.UI.ModuleInjection
  [Expand]DevExpress.Xpf.Accordion
  [Expand]DevExpress.Xpf.Bars
  [Expand]DevExpress.Xpf.Carousel
  [Expand]DevExpress.Xpf.Charts
  [Expand]DevExpress.Xpf.Charts.Localization
  [Expand]DevExpress.Xpf.Charts.RangeControlClient
  [Expand]DevExpress.Xpf.ChunkList
  [Expand]DevExpress.Xpf.Controls
  [Expand]DevExpress.Xpf.Core
  [Expand]DevExpress.Xpf.Core.ConditionalFormatting
  [Expand]DevExpress.Xpf.Core.DataSources
  [Expand]DevExpress.Xpf.Core.FilteringUI
  [Expand]DevExpress.Xpf.Core.Native
  [Expand]DevExpress.Xpf.Core.ServerMode
  [Expand]DevExpress.Xpf.Data
  [Expand]DevExpress.Xpf.DataAccess
  [Expand]DevExpress.Xpf.DataAccess.DataSourceWizard
  [Expand]DevExpress.Xpf.Diagram
  [Expand]DevExpress.Xpf.Dialogs
  [Expand]DevExpress.Xpf.Docking
  [Expand]DevExpress.Xpf.Docking.Base
  [Expand]DevExpress.Xpf.DocumentViewer
  [Expand]DevExpress.Xpf.DXBinding
  [Expand]DevExpress.Xpf.Editors
  [Expand]DevExpress.Xpf.Editors.DataPager
  [Expand]DevExpress.Xpf.Editors.DateNavigator
  [Expand]DevExpress.Xpf.Editors.ExpressionEditor
  [Expand]DevExpress.Xpf.Editors.ExpressionEditor.Native
  [Expand]DevExpress.Xpf.Editors.Filtering
  [Expand]DevExpress.Xpf.Editors.Flyout
  [Expand]DevExpress.Xpf.Editors.Flyout.Native
  [Expand]DevExpress.Xpf.Editors.Helpers
  [Expand]DevExpress.Xpf.Editors.Native
  [Expand]DevExpress.Xpf.Editors.Popups
  [Expand]DevExpress.Xpf.Editors.RangeControl
  [Expand]DevExpress.Xpf.Editors.Settings
  [Expand]DevExpress.Xpf.Editors.Validation
  [Expand]DevExpress.Xpf.ExpressionEditor
  [Expand]DevExpress.Xpf.Gantt
  [Expand]DevExpress.Xpf.Gauges
  [Expand]DevExpress.Xpf.Gauges.Localization
  [Expand]DevExpress.Xpf.Grid
  [Expand]DevExpress.Xpf.Grid.ConditionalFormatting
  [Expand]DevExpress.Xpf.Grid.LookUp
  [Expand]DevExpress.Xpf.Grid.TreeList
  [Expand]DevExpress.Xpf.Layout.Core
  [Expand]DevExpress.Xpf.LayoutControl
  [Expand]DevExpress.Xpf.Map
  [Expand]DevExpress.Xpf.NavBar
  [Expand]DevExpress.Xpf.Navigation
  [Expand]DevExpress.Xpf.PdfViewer
  [Expand]DevExpress.Xpf.PivotGrid
  [Expand]DevExpress.Xpf.PivotGrid.Printing
  [Expand]DevExpress.Xpf.Printing
  [Expand]DevExpress.Xpf.Printing.Parameters
  [Expand]DevExpress.Xpf.Printing.Parameters.Models
  [Expand]DevExpress.Xpf.Printing.PreviewControl
  [Expand]DevExpress.Xpf.Printing.PreviewControl.Bars
  [Expand]DevExpress.Xpf.Prism
  [Expand]DevExpress.Xpf.PropertyGrid
  [Expand]DevExpress.Xpf.Reports.UserDesigner
  [Expand]DevExpress.Xpf.Reports.UserDesigner.Extensions
  [Expand]DevExpress.Xpf.Reports.UserDesigner.Localization
  [Expand]DevExpress.Xpf.Reports.UserDesigner.ReportWizard
  [Expand]DevExpress.Xpf.Reports.UserDesigner.ReportWizard.Pages
  [Expand]DevExpress.Xpf.Ribbon
  [Collapse]DevExpress.Xpf.RichEdit
    CommandBarStyle Enumeration
   [Expand]ContentToHtmlConverter Class
   [Expand]ContentToMhtConverter Class
   [Expand]ContentToOpenDocumentConverter Class
   [Expand]ContentToOpenXmlConverter Class
   [Expand]ContentToPlainTextConverter Class
   [Expand]ContentToRtfConverter Class
   [Expand]ContentToSpecificFormatConverter Class
   [Expand]ContentToWordMLConverter Class
   [Expand]CustomMarkDrawEventArgs Class
    CustomMarkDrawEventHandler Delegate
   [Expand]DXRichEditAuthenticationOptions Class
   [Expand]DXRichEditAutoCorrectOptions Class
   [Expand]DXRichEditBehaviorOptions Class
   [Expand]DXRichEditBookmarkOptions Class
   [Expand]DXRichEditCommentOptions Class
   [Expand]DXRichEditCopyPasteOptions Class
   [Expand]DXRichEditDataFormatOptions Class
   [Expand]DXRichEditDocDocumentExporterCompatibilityOptions Class
   [Expand]DXRichEditDocDocumentExporterOptions Class
   [Expand]DXRichEditDocDocumentImporterOptions Class
   [Expand]DXRichEditDocumentCapabilitiesOptions Class
   [Expand]DXRichEditDocumentExportOptions Class
   [Expand]DXRichEditDocumentImportOptions Class
   [Expand]DXRichEditDocumentSaveOptions Class
   [Expand]DXRichEditDocumentSearchOptions Class
   [Expand]DXRichEditFieldOptions Class
   [Expand]DXRichEditFormattingMarkVisibilityOptions Class
   [Expand]DXRichEditHorizontalRulerOptions Class
   [Expand]DXRichEditHtmlDocumentExporterOptions Class
   [Expand]DXRichEditHtmlDocumentImporterOptions Class
   [Expand]DXRichEditHyperlinkOptions Class
   [Expand]DXRichEditLayoutOptions Class
   [Expand]DXRichEditMailMergeOptions Class
   [Expand]DXRichEditMhtDocumentExporterOptions Class
   [Expand]DXRichEditMhtDocumentImporterOptions Class
   [Expand]DXRichEditNumberingOptions Class
   [Expand]DXRichEditOpenDocumentExporterOptions Class
   [Expand]DXRichEditOpenDocumentImporterOptions Class
   [Expand]DXRichEditOpenXmlDocumentExporterOptions Class
   [Expand]DXRichEditOpenXmlDocumentImporterOptions Class
   [Expand]DXRichEditPlainTextDocumentExporterOptions Class
   [Expand]DXRichEditPlainTextDocumentImporterOptions Class
   [Expand]DXRichEditPrintingOptions Class
   [Expand]DXRichEditRangePermissionOptions Class
   [Expand]DXRichEditRtfDocumentExporterCompatibilityOptions Class
   [Expand]DXRichEditRtfDocumentExporterOptions Class
   [Expand]DXRichEditRtfDocumentImporterOptions Class
   [Expand]DXRichEditSpellCheckerOptions Class
   [Expand]DXRichEditTableOptions Class
   [Expand]DXRichEditUpdateFieldOptions Class
   [Expand]DXRichEditVerticalRulerOptions Class
   [Expand]DXRichEditWordMLDocumentExporterOptions Class
   [Expand]DXRichEditWordMLDocumentImporterOptions Class
   [Expand]HoverMenuShowingEventArgs Class
    HoverMenuShowingEventHandler Delegate
   [Expand]HtmlToContentConverter Class
   [Expand]IRichEditDocumentLoader Interface
   [Expand]MhtToContentConverter Class
   [Expand]OpenDocumentToContentConverter Class
   [Expand]OpenXmlToContentConverter Class
   [Expand]PlainTextToContentConverter Class
   [Expand]PopupMenuShowingEventArgs Class
    PopupMenuShowingEventHandler Delegate
   [Collapse]RichEditControl Class
     RichEditControl Members
     RichEditControl Constructor
    [Expand]RichEditControl Properties
    [Collapse]RichEditControl Events
      ActiveRecordChanged Event
      ActiveRecordChanging Event
      ActiveViewChanged Event
      AfterExport Event
      AutoCorrect Event
      BeforeExport Event
      BeforeImport Event
      BeforePagePaint Event
      CalculateDocumentVariable Event
      ClipboardSetDataException Event
      CloseReviewingPane Event
      CommentInserted Event
      ContentChanged Event
      CustomizeMergeFields Event
      CustomMarkDraw Event
      CustomPropertiesChanged Event
      DecryptionFailed Event
      DocBytesChanged Event
      DocumentClosing Event
      DocumentEncryptionChanged Event
      DocumentLoaded Event
      DocumentPropertiesChanged Event
      DocumentProtectionChanged Event
      EmptyDocumentCreated Event
      EncryptedFileIntegrityCheckFailed Event
      EncryptedFilePasswordCheckFailed Event
      EncryptedFilePasswordRequested Event
      FinishHeaderFooterEditing Event
      HoverMenuShowing Event
      HtmlTextChanged Event
      HyperlinkClick Event
      InitializeDocument Event
      InvalidFormatException Event
      MailMergeFinished Event
      MailMergeRecordFinished Event
      MailMergeRecordStarted Event
      MailMergeStarted Event
      MhtTextChanged Event
      ModifiedChanged Event
      OpenDocumentBytesChanged Event
      OpenXmlBytesChanged Event
      OvertypeChanged Event
      PopupMenuShowing Event
      PrepareHoverMenu Event
      PreparePopupMenu Event
      PropertyChanged Event
      ReadOnlyChanged Event
      RtfTextChanged Event
      SearchBoxClosed Event
      SelectionChanged Event
      SpellingErrorLimitExceeded Event
      StartHeaderFooterEditing Event
      TextChanged Event
      UnhandledException Event
      UnitChanged Event
      UnitChanging Event
      UpdateUI Event
      VisiblePagesChanged Event
      WordMLTextChanged Event
      ZoomChanged Event
    [Expand]RichEditControl Methods
   [Expand]RichEditControlOptions Class
   [Expand]RichEditDocumentContent Structure
   [Expand]RichEditDocumentSource Class
   [Expand]RichEditDocumentXpfPrinter Class
   [Expand]RichEditHoverMenu Class
    RichEditMenuType Enumeration
   [Expand]RtfToContentConverter Class
   [Expand]SpecificFormatToContentConverter Class
   [Expand]WordMLToContentConverter Class
  [Expand]DevExpress.Xpf.RichEdit.Menu
  [Expand]DevExpress.Xpf.Scheduler
  [Expand]DevExpress.Xpf.Scheduler.Drawing
  [Expand]DevExpress.Xpf.Scheduler.Menu
  [Expand]DevExpress.Xpf.Scheduler.Reporting
  [Expand]DevExpress.Xpf.Scheduler.UI
  [Expand]DevExpress.Xpf.Scheduling
  [Expand]DevExpress.Xpf.Scheduling.Common
  [Expand]DevExpress.Xpf.Scheduling.Editors
  [Expand]DevExpress.Xpf.Scheduling.iCalendar
  [Expand]DevExpress.Xpf.Scheduling.Reporting
  [Expand]DevExpress.Xpf.Scheduling.Visual
  [Expand]DevExpress.Xpf.Scheduling.VisualData
  [Expand]DevExpress.Xpf.SpellChecker
  [Expand]DevExpress.Xpf.Spreadsheet
  [Expand]DevExpress.Xpf.Spreadsheet.Menu
  [Expand]DevExpress.Xpf.TreeMap
  [Expand]DevExpress.Xpf.Utils.Themes
  [Expand]DevExpress.Xpf.WindowsUI
  [Expand]DevExpress.Xpf.WindowsUI.Internal
  [Expand]DevExpress.Xpf.WindowsUI.Navigation
  [Expand]DevExpress.XtraRichEdit
  [Expand]DevExpress.XtraRichEdit.Printing
[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]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)

RichEditControl.CalculateDocumentVariable Event

Fires when the DOCVARIABLE field is updated.

Namespace:DevExpress.Xpf.RichEdit
Assembly:DevExpress.Xpf.RichEdit.v19.1.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 for the DOCVARIABLE field. The event is fired when a field is updated (using UI commands, DevExpress.XtraRichEdit.API.Native.Field.Update or DevExpress.XtraRichEdit.API.Native.FieldCollection.Update methods), or during the Mail Merge on the MailMerge method call. Handle this event to analyze DOCVARIABLE field switches and arguments, and provide custom content to insert into this field.

You can specify the UpdateLockField (see DevExpress.XtraRichEdit.FieldOptions.UpdateLockedFields) property to raise the event for locked DOCVARIABLE fields.

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

Note

Always provide a check for the e.Arguments[0] value with nested fields (such as {DOCVARIABLE {MERGEFIELD MyDataField_1}}). When the CalculateDocumentVariable event is fired for the first time, e.Arguments[0] contains the <<MyDataField_1>> (the placeholder for the field) since the merge field is not yet calculated. Do not handle the event if the argument is invalid (use comparison and return statements if required) .

This code snippet demonstrates how to handle the DevExpress.XtraRichEdit.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' DevExpress.XtraRichEdit.CalculateDocumentVariableEventArgs.Value property to the DevExpress.XtraRichEdit.DocVariableValue.Current value in the CalculateDocumentVariable event handler to save the initial DOCVARIABLE field value.

Expanded See Also

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