Back to Devexpress

RichEditControlOptionsBase.Fields Property

officefileapi-devexpress-dot-xtrarichedit-dot-richeditcontroloptionsbase-5d6433fc.md

latest3.9 KB
Original Source

RichEditControlOptionsBase.Fields Property

Gets document field options.

Namespace : DevExpress.XtraRichEdit

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public FieldOptions Fields { get; }
vb
Public ReadOnly Property Fields As FieldOptions

Property Value

TypeDescription
FieldOptions

An object that contains document field options.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to Fields
IRichEditDocumentServer

.Options .Fields

| | RichEditDocumentServer |

.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.

csharp
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();
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
'...

Using wordProcessor As New RichEditDocumentServer()
    ' Specify field options.
    Dim fieldOptions As 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.
    Dim document As Document = wordProcessor.Document

    ' Insert a text box in the document.
    Dim myTextBox As Shape = document.Shapes.InsertTextBox(document.Range.Start)

    ' Access text box content.
    Dim textBoxDocument1 As SubDocument = myTextBox.ShapeFormat.TextBox.Document

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

    ' Update the field.
    textBoxDocument.Fields.Update()
End Using

See Also

RichEditControlOptionsBase Class

RichEditControlOptionsBase Members

DevExpress.XtraRichEdit Namespace