Skip to main content

FieldCollection.Create(DocumentRange) Method

Creates a field from the specified range and adds it to the field collection.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v26.1.Core.dll

NuGet Package: DevExpress.RichEdit.Core

Declaration

Field Create(
    DocumentRange range
)

Parameters

Name Type Description
range DocumentRange

A DocumentRange object specifying a range to be transformed to a field.

Returns

Type Description
Field

A Field object specifying the newly created field.

Example

The code sample below inserts text and converts it to the SYMBOL field.

View Example

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

//...
using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
    Document document = wordProcessor.Document;

    // Start to edit the document.
    document.BeginUpdate();

    // Append text.
    document.AppendText("SYMBOL 0x54 \\f Wingdings \\s 24");

    // Convert inserted text to a field.
    document.Fields.Create(document.Paragraphs[0].Range);

    // Update all fields.
    document.Fields.Update();

    // Finalize to edit the document.
    document.EndUpdate();

    // Save the result
    document.SaveDocument("Result.docx", DocumentFormat.Docx);
}
See Also