Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

FieldOptions Class

Contains options used to define the appearance and behavior of the document fields.

Namespace: DevExpress.XtraRichEdit

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

NuGet Package: DevExpress.RichEdit.Core

#Declaration

[ComVisible(true)]
public class FieldOptions :
    RichEditNotificationOptions

The following members return FieldOptions objects:

#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