FieldChar

FieldChar class

Base class for nodes that represent field characters in a document.

public abstract class FieldChar : SpecialChar

Properties

Name Description
CustomNodeId { get; set; } Specifies custom node identifier.
virtual Document { get; } Gets the document to which this node belongs.
FieldType { get; } Returns the type of the field.
Font { get; } Provides access to the font formatting of this object.
virtual IsComposite { get; } Returns true if this node can contain other nodes.
IsDeleteRevision { get; } Returns true if this object was deleted in Microsoft Word while change tracking was enabled.
IsDirty { get; set; } Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document.
IsFormatRevision { get; } Returns true if formatting of the object was changed in Microsoft Word while change tracking was enabled.
IsInsertRevision { get; } Returns true if this object was inserted in Microsoft Word while change tracking was enabled.
IsLocked { get; set; } Gets or sets whether the parent field is locked (should not recalculate its result).
IsMoveFromRevision { get; } Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
IsMoveToRevision { get; } Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
NextSibling { get; } Gets the node immediately following this node.
override NodeType { get; } Returns NodeType.SpecialChar.
ParentNode { get; } Gets the immediate parent of this node.
ParentParagraph { get; } Retrieves the parent Paragraph of this node.
PreviousSibling { get; } Gets the node immediately preceding this node.
Range { get; } Returns a Range object that represents the portion of a document that is contained in this node.

Methods

Name Description
override Accept(DocumentVisitor) Accepts a visitor.
Clone(bool) Creates a duplicate of the node.
GetAncestor(NodeType) Gets the first ancestor of the specified NodeType.
GetAncestor(Type) Gets the first ancestor of the specified object type.
GetField() Returns a field for the field char.
override GetText() Gets the special character that this node represents.
NextPreOrder(Node) Gets next node according to the pre-order tree traversal algorithm.
PreviousPreOrder(Node) Gets the previous node according to the pre-order tree traversal algorithm.
Remove() Removes itself from the parent.
ToString(SaveFormat) Exports the content of the node into a string in the specified format.
ToString(SaveOptions) Exports the content of the node into a string using the specified save options.

Remarks

A complete field in a Microsoft Word document is a complex structure consisting of a field start character, field code, field separator character, field result and field end character. Some fields only have field start, field code and field end.

To easily insert a new field into a document, use the InsertField method.

Examples

Shows how to work with a FieldStart node.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

FieldDate field = (FieldDate)builder.InsertField(FieldType.FieldDate, true);
field.Format.DateTimeFormat = "dddd, MMMM dd, yyyy";
field.Update();

FieldChar fieldStart = field.Start;

Assert.AreEqual(FieldType.FieldDate, fieldStart.FieldType);
Assert.AreEqual(false, fieldStart.IsDirty);
Assert.AreEqual(false, fieldStart.IsLocked);

// Retrieve the facade object which represents the field in the document.
field = (FieldDate)fieldStart.GetField();

Assert.AreEqual(false, field.IsLocked);
Assert.AreEqual(" DATE  \\@ \"dddd, MMMM dd, yyyy\"", field.GetFieldCode());

// Update the field to show the current date.
field.Update();

See Also