Skip to main content

FieldCollection.Create(DocumentPosition, String) Method

Adds a field specified by its code to the field collection.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

Declaration

Field Create(
    DocumentPosition start,
    string code
)

Parameters

Name Type Description
start DocumentPosition

A DocumentPosition at which the field is inserted.

code String

A string specifying the field’s code.

Returns

Type Description
Field

A Field object specifying the newly created field.

Example

The code snippet below uses the SYMBOL field to add a check mark (✔) to the document:

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

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

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

    // Create the "SYMBOL" field.
    document.Fields.Create(document.Range.Start, "SYMBOL 252 \\f Wingdings \\s 28");

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

    // Update all fields in the main document body.
    document.Fields.Update();

    // Save the document to the file.
    document.SaveDocument("Result.docx", DocumentFormat.OpenXml);
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the Create(DocumentPosition, String) 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