.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

RichEditControlOptionsBase.Fields Property

Gets document field options.

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.RichEdit.v21.2.Core.dll

Declaration

public FieldOptions Fields { get; }

Property Value

Type Description
FieldOptions

An object that contains document field options.

Property Paths

You can access this nested property as listed below:

Library Object Type Path to Fields
WinForms Controls SnapControl
.Options.Fields
RichEditControl
.Options.Fields
WPF Controls RichEditControl
.Options.Fields
Office File API IRichEditDocumentServer
.Options.Fields
RichEditDocumentServer
.Options.Fields
Reporting SyntaxEditor
.Options.Fields

Remarks

The FieldOptions define the appearance and behavior of the document fields.

Example

The code snippet below demonstrates how to specify field options.

Specify Field Options

using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
//...

using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
    // Specify field options.
    FieldOptions fieldOptions = wordProcessor.Options.Fields;
    fieldOptions.HighlightMode = FieldsHighlightMode.Always;
    fieldOptions.HighlightColor = System.Drawing.Color.LightSalmon;
    fieldOptions.UseCurrentCultureDateTimeFormat = true;
    fieldOptions.ThrowExceptionOnInvalidFormatSwitch = true;
    fieldOptions.UpdateFieldsInTextBoxes = true;

    // Access a document.
    Document document = wordProcessor.Document;

    // Insert a text box in the document.
    Shape myTextBox = document.Shapes.InsertTextBox(document.Range.Start);

    // Access text box content.
    SubDocument textBoxDocument1 = myTextBox.ShapeFormat.TextBox.Document;

    // Create the "DATE" field.
    textBoxDocument.Fields.Create(textBoxDocument.Range.Start, "DATE");

    // Update the field.
    textBoxDocument.Fields.Update();
}
See Also