FieldCollection.Create(DocumentPosition, String) Method
Adds a field specified by its code to the field collection.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v26.1.Core.dll
NuGet Package: DevExpress.RichEdit.Core
Declaration
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.Docx);
}
See Also