Back to Devexpress

How to: Insert Dynamic Content

windowsforms-401204-controls-and-libraries-rich-text-editor-examples-automation-how-to-insert-dynamic-content.md

latest1.8 KB
Original Source

How to: Insert Dynamic Content

  • Feb 17, 2023
  • 3 minutes to read

The code sample below shows how use the DOCVARIABLE field and RichEditControl.CalculateDocumentVariable event to insert dynamic (formatted) content. In this example, the DOCVARIABLE field is used to display the DevExpress community website’s RSS feed.

Note

A complete sample project is available at Dynamic Content demo module.

  1. Load a document template, if required.

  2. Insert a DOCVARIABLE field. Use the FieldCollection.Create method, as shown below:

  3. Use the RichEditDocumentServer object to generate or load the target dynamic content. In this example, the GenerateRssFeed method returns this RichEditDocumentServer object.

  4. Handle the RichEditControl.CalculateDocumentVariable event. Use the RichEditDocumentServer object created in the previous step as the CalculateDocumentVariableEventArgs.Value property value. Identify the field by the CalculateDocumentVariableEventArgs.VariableName property value.

  5. Call the FieldCollection.Update to update all document fields.