Table of Contents

Class FormField

Namespace
DocWright.Dom.Forms
Assembly
DocWright.Dom.dll

A legacy form field — the FORMTEXT, FORMCHECKBOX and FORMDROPDOWN fields Word wrote before content controls existed, and still writes for documents in compatibility mode.

A legacy form field is a field chain whose begin character carries a w:ffData element (ECMA-376 Part 1 §17.16.17). Phase 14 already parses the instruction; this type adds the w:ffData half, which the reader has been preserving as an island on the begin run since Phase 1.

Editing works the same way content controls do: typed properties are a view over the preserved island, and a setter splices it. An edit the rewriter cannot place with certainty throws FormFieldEditException and changes nothing.

Macros are preserved, never run. EntryMacro and ExitMacro report the names a document recorded. DocWright does not execute them and has no mechanism to.

public sealed class FormField
Inheritance
FormField
Inherited Members

Properties

CalculateOnExit

Gets whether fields recalculate when this one is exited (w:calcOnExit).

CheckBoxSize

Gets a check box's size in half-points (w:checkBox/w:size), or null when it sizes itself from the surrounding text (w:sizeAuto).

CheckBoxSizesAutomatically

Gets whether a check box sizes itself from the surrounding text (w:checkBox/w:sizeAuto).

CheckedState

Gets the checked state the document states for a check box (w:checkBox/w:checked), or null when the element is absent and the box shows its default, IsCheckedByDefault.

DefaultIndex

Gets the zero-based index of the default entry (w:ddList/w:default). Zero when unstated.

DefaultText

Gets a text field's default content (w:textInput/w:default), or null.

DropDownEntries

Gets a drop-down's entries, in order (w:ddList/w:listEntry). Empty for every other kind.

EntryMacro

Gets the macro run on entry (w:entryMacro), or null. Preserved, never executed.

ExitMacro

Gets the macro run on exit (w:exitMacro), or null. Preserved, never executed.

HelpText

Gets the help text shown on F1 (w:helpText), or null.

IsChecked

Gets or sets whether a check box is checked (w:checkBox/w:checked).

IsCheckedByDefault

Gets whether a check box is checked by default (w:checkBox/w:default).

IsEnabled

Gets whether the field may be filled in (w:enabled). True when the element is absent, which is Word's default.

Kind

Gets the field's kind, determined by the type-specific child of w:ffData.

MaxLength

Gets a text field's maximum length in characters (w:textInput/w:maxLength), or null when unlimited. Word writes -1 for unlimited, which is reported as null.

Name

Gets or sets the bookmark name Word gives the field (w:name), or null.

RawXml

Gets the preserved w:ffData markup.

Region

Gets the field region this form field wraps.

SelectedIndex

Gets or sets the zero-based index of the selected entry (w:ddList/w:result). Zero when unstated, which is Word's default.

StatusText

Gets the text shown in the status bar (w:statusText), or null.

TextFormat

Gets a text field's format string (w:textInput/w:format), or null. Word uses this for casing on a regular field (UPPERCASE, Title case) and a numeric or date picture otherwise.

TextType

Gets what a text field accepts (w:textInput/w:type). Regular when unstated.

Methods

Flatten()

Replaces the whole field — its markup, its w:ffData and its result — with the field's current value as ordinary text.

GetValue()

Returns the field's current value: the displayed result for a text field, the state of a check box as true/false, and the selected entry of a drop-down.

SetValue(string)

Fills the field in: updates the stored state and the displayed result together.