Click or drag to resize
Field Class
Provides a mechanism for placeholders, such as page reference numbers, which can be added to a document such that those placeholders are replaced by their corresponding values when the document is rendered for display or print.
Inheritance Hierarchy

Namespace:  GemBox.Document
Assembly:  GemBox.Document (in GemBox.Document.dll) Version: 25.3.30.1243
Syntax
public sealed class Field : Inline, 
	IContentElement

The Field type exposes the following members.

Constructors
  NameDescription
Public methodField(DocumentModel, FieldType)
Initializes a new instance of the Field class.
Public methodField(DocumentModel, FieldType, Inline)
Initializes a new instance of the Field class.
Public methodField(DocumentModel, FieldType, IEnumerableInline, Inline)
Initializes a new instance of the Field class.
Public methodField(DocumentModel, FieldType, IEnumerableInline, IEnumerableInline)
Initializes a new instance of the Field class.
Public methodField(DocumentModel, FieldType, String, Inline)
Initializes a new instance of the Field class.
Public methodField(DocumentModel, FieldType, String, IEnumerableInline)
Initializes a new instance of the Field class.
Public methodField(DocumentModel, FieldType, String, String)
Initializes a new instance of the Field class.
Top
Properties
  NameDescription
Public propertyCharacterFormat
Gets or sets the character format.
Public propertyContent
Gets the content of the current Element.
(Inherited from Element.)
Public propertyDocument
Gets the owner document.
(Overrides ElementDocument.)
Public propertyElementType
Gets the ElementType of this Element instance.
(Overrides ElementElementType.)
Public propertyFieldType
Gets the field type.
Public propertyFormData
Gets the form related data associated with the parent form field or if parent field is not form field.
Public propertyInstructionInlines
Gets the field instruction Inlines.
Public propertyIsDirty
Gets or sets a value indicating whether the result of this field is invalid and, because of that, it should be updated.
Public propertyParent
Gets the parent of this Element instance.
(Inherited from Element.)
Public propertyParentCollection
Gets the InlineCollection that contains this Inline instance.
(Inherited from Inline.)
Public propertyResultInlines
Gets the field result Inlines.
Top
Methods
  NameDescription
Public methodClone
Clones this Field instance, and optionally clones it's result.
Public methodGetChildElements(Boolean)
Gets the child elements.
(Inherited from Element.)
Public methodGetChildElements(Boolean, ElementType)
Gets the child elements filtered by ElementType.
(Inherited from Element.)
Public methodGetInstructionText
Gets the field instruction text if InstructionInlines contains only Runs, SpecialCharacters and bookmarks; otherwise Empty.
Top
Explicit Interface Implementations
Remarks

Fields are used in a mail merge and, usually, in scenarios where document information can be resolved only when document is rendered (for example, page numbers).

GemBox.Document supports nested fields - another field can be contained in an InstructionInlines or a ResultInlines properties of a field.

Fields are defined by the Field.FieldType and, optionally, Field.InstructionInlines that usually contains field arguments and switches, but can also contain other fields, and Field.ResultInlines that contains the latest field's value.

GemBox.Document doesn't have a resolver or a calculation engine that refreshes field's result based on its field type and instruction text. Field's result is simply read from and written to a document file. To refresh a field result you must use Microsoft Word. Field result refreshing can be expected to be implemented in a future versions of GemBox.Document.

If Field.InstructionInlines contains only Runs, you can use Field.GetInstructionText() to retrieve instruction as a String.

For a field creation example, see fields sample.
See Also