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.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

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.OpenXml);
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the Create(DocumentRange) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also