FormField Class
Represents a single form field.
Inheritance Hierarchy
SystemObject
  Aspose.WordsNode
    Aspose.WordsInline
      Aspose.WordsSpecialChar
        Aspose.Words.FieldsFormField

Namespace: Aspose.Words.Fields
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
Syntax
public class FormField : SpecialChar

The FormField type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleCalculateOnExit
True if references to the specified form field are automatically updated whenever the field is exited.
Public propertyCode exampleCheckBoxSize
Gets or sets the size of the checkbox in points. Has effect only when IsCheckBoxExactSize is true.
Public propertyCode exampleChecked
Gets or sets the checked status of the check box form field. Default value for this property is false.
Public propertyCode exampleDefault
Gets or sets the default value of the check box form field. Default value for this property is false.
Public propertyCode exampleDocument
Gets the document to which this node belongs.
(Inherited from Node.)
Public propertyCode exampleDropDownItems
Provides access to the items of a dropdown form field.
Public propertyCode exampleDropDownSelectedIndex
Gets or sets the index specifying the currently selected item in a dropdown form field.
Public propertyCode exampleEnabled
True if a form field is enabled.
Public propertyCode exampleEntryMacro
Returns or sets an entry macro name for the form field.
Public propertyCode exampleExitMacro
Returns or sets an exit macro name for the form field.
Public propertyCode exampleFont
Provides access to the font formatting of this object.
(Inherited from Inline.)
Public propertyCode exampleHelpText
Returns or sets the text that's displayed in a message box when the form field has the focus and the user presses F1.
Public propertyCode exampleIsCheckBoxExactSize
Gets or sets the boolean value that indicates whether the size of the textbox is automatic or specified explicitly.
Public propertyCode exampleIsComposite
Returns true if this node can contain other nodes.
(Inherited from Node.)
Public propertyCode exampleIsDeleteRevision
Returns true if this object was deleted in Microsoft Word while change tracking was enabled.
(Inherited from Inline.)
Public propertyCode exampleIsFormatRevision
Returns true if formatting of the object was changed in Microsoft Word while change tracking was enabled.
(Inherited from Inline.)
Public propertyCode exampleIsInsertRevision
Returns true if this object was inserted in Microsoft Word while change tracking was enabled.
(Inherited from Inline.)
Public propertyCode exampleIsMoveFromRevision
Returns true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
(Inherited from Inline.)
Public propertyCode exampleIsMoveToRevision
Returns true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
(Inherited from Inline.)
Public propertyCode exampleMaxLength
Maximum length for the text field. Zero when the length is not limited.
Public propertyCode exampleName
Gets or sets the form field name.
Public propertyCode exampleNextSibling
Gets the node immediately following this node.
(Inherited from Node.)
Public propertyCode exampleNodeType
Returns NodeType.FormField.
(Overrides SpecialCharNodeType.)
Public propertyCode exampleOwnHelp
Specifies the source of the text that's displayed in a message box when a form field has the focus and the user presses F1.
Public propertyCode exampleOwnStatus
Specifies the source of the text that's displayed in the status bar when a form field has the focus.
Public propertyCode exampleParentNode
Gets the immediate parent of this node.
(Inherited from Node.)
Public propertyCode exampleParentParagraph
Retrieves the parent Paragraph of this node.
(Inherited from Inline.)
Public propertyCode examplePreviousSibling
Gets the node immediately preceding this node.
(Inherited from Node.)
Public propertyCode exampleRange
Returns a Range object that represents the portion of a document that is contained in this node.
(Inherited from Node.)
Public propertyCode exampleResult
Gets or sets a string that represents the result of this form field.
Public propertyCode exampleStatusText
Returns or sets the text that's displayed in the status bar when a form field has the focus.
Public propertyCode exampleTextInputDefault
Gets or sets the default string or a calculation expression of a text form field.
Public propertyCode exampleTextInputFormat
Returns or sets the text formatting for a text form field.
Public propertyCode exampleTextInputType
Gets or sets the type of a text form field.
Public propertyCode exampleType
Returns the form field type.
Methods
  NameDescription
Public methodCode exampleAccept
Accepts a visitor.
(Overrides SpecialCharAccept(DocumentVisitor).)
Public methodCode exampleClone (Inherited from Node.)
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodCode exampleGetAncestor(Type)
Gets the first ancestor of the specified object type.
(Inherited from Node.)
Public methodCode exampleGetAncestor(NodeType)
Gets the first ancestor of the specified NodeType.
(Inherited from Node.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetText
Gets the special character that this node represents.
(Inherited from SpecialChar.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodCode exampleNextPreOrder
Gets next node according to the pre-order tree traversal algorithm.
(Inherited from Node.)
Public methodCode examplePreviousPreOrder
Gets the previous node according to the pre-order tree traversal algorithm.
(Inherited from Node.)
Public methodCode exampleRemove
Removes itself from the parent.
(Inherited from Node.)
Public methodCode exampleRemoveField
Removes the complete form field, not just the form field special character.
Public methodCode exampleSetTextInputValue
Applies the text format specified in TextInputFormat and stores the value in Result.
Public methodToString (Inherited from Object.)
Public methodCode exampleToString(SaveFormat)
Exports the content of the node into a string in the specified format.
(Inherited from Node.)
Public methodCode exampleToString(SaveOptions)
Exports the content of the node into a string using the specified save options.
(Inherited from Node.)
Remarks

Microsoft Word provides the following form fields: checkbox, text input and dropdown (combobox).

FormField is an inline-node and can only be a child of Paragraph.

FormField is represented in a document by a special character and positioned as a character within a line of text.

A complete form field in a Word document is a complex structure represented by several nodes: field start, field code such as FORMTEXT, form field data, field separator, field result, field end and a bookmark. To programmatically create form fields in a Word document use DocumentBuilder.InsertCheckBox, DocumentBuilder.InsertTextInput and DocumentBuilder.InsertComboBox which make sure all of the form field nodes are created in a correct order and in a suitable state.

Examples
Shows how to work with form field name, type, and result.
Document doc = new Document(MyDir + "FormFields.doc");

FormField formField = doc.Range.FormFields[3];

if (formField.Type.Equals(FieldType.FieldFormTextInput))
    formField.Result = "My name is " + formField.Name;
Examples
Shows how to access form fields.
Document doc = new Document(MyDir + "FormFields.doc");
FormFieldCollection documentFormFields = doc.Range.FormFields;

FormField formField1 = documentFormFields[3];
FormField formField2 = documentFormFields["CustomerName"];
See Also