# Content Controls and Word Form Fields

> Create MS Word content controls and read legacy form fields in Windows Forms with ApplicationFieldFormat, ContentControlFieldAdapter, FormText and NextField.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Document Processing > Content Controls and Word Form Fields
- **4577 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/content-controls/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/content-controls/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/content-controls/llms-full.txt

---

Forms and templates made in MS Word hold two kinds of controls: content controls, such as plain text boxes, check boxes, drop-down lists and date pickers, and the older legacy form fields `FORMTEXT`, `FORMCHECKBOX` and `FORMDROPDOWN`. TX Text Control .NET for Windows Forms loads both. Depending on a load setting, they become form fields that users fill out in the `TextControl`, or application fields that keep all Word-specific settings, such as the title and tag of a content control, and that the field adapter classes of `TXTextControl.DocumentServer.Fields` make accessible in code.

The handlers go into *Form1.cs* with the `TextControl` named `textControl1` and need `using TXTextControl;` and `using TXTextControl.DocumentServer.Fields;`. Form fields that you create in TX Text Control itself are the subject of [Forms and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/form-fields/llms-full.txt), and fields in general of [Fields and Subtext Parts](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/fields/llms-full.txt).

### How Word Controls Are Loaded

Content controls exist since MS Word 2007 and replace the legacy form fields; both are stored in DOCX files. Of the MS Word formats, only DOCX carries content controls: the MS Word 97-2003 format doesn't support them. When you load a document, [LoadSettings.ApplicationFieldFormat](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/loadsettings/applicationfieldformat-property/llms-full.txt) decides what becomes of them:

With the default `None` and with `MSWordTXFormFields`, content controls and legacy form fields become form fields in [FormFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/formfields-property/llms-full.txt); with `MSWord`, they become application fields in [ApplicationFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/applicationfields-property/llms-full.txt). [Control the Import With LoadSettings](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/loading/#control-the-import-with-loadsettings) lists all values of [ApplicationFieldFormat](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/applicationfieldformat/enumeration/llms-full.txt) and what they do with the other Word fields.

Choose form fields when users fill out the form in the editor or your code reads and sets its values: they are the `TextFormField`, `CheckFormField`, `SelectionFormField` and `DateFormField` objects that [Form Fields and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/llms-full.txt) describes, and they are saved back to DOCX as content controls. Choose application fields when your code needs what only Word knows about a control, or when it creates Word controls itself. The rest of this page works with application fields.

### Field Adapters

An [ApplicationField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/applicationfield/llms-full.txt) stores a Word field or control as its type name and its parameters, which are written in the XML syntax of Office Open XML. A field adapter wraps an application field and offers its settings as typed properties, so that your code doesn't parse that XML. Every adapter derives from [FieldAdapter](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/fieldadapter/llms-full.txt):

```text
FieldAdapter
+-- MailMergeFieldAdapter        MergeField, IfField, IncludeText, DateField, NextField, NextIfField
+-- FormFieldAdapter             FormText, FormCheckBox, FormDropDown
+-- ContentControlFieldAdapter   PlainTextContentControl, RichTextContentControl, CheckBoxContentControl,
                                 ComboBoxContentControl, DropDownListContentControl, DateContentControl
```

Each adapter class has two constructors. Without a parameter, it creates a new field, whose [ApplicationField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/fieldadapter/applicationfield-property/llms-full.txt) you add to the document. With an existing `ApplicationField`, it wraps that field, and every property you set changes the field in the document. [FieldAdapter.ShowDialog](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/fieldadapter/showdialog-method/llms-full.txt) opens the options dialog box of a field; pass your form as the owner window. The merge field adapters are covered in [Merge Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/fields/llms-full.txt), [Conditional Content](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/conditional-content/llms-full.txt) and [Subtemplates](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/subtemplates/llms-full.txt).

### Create Content Controls

To add a content control, create the adapter of its type, set its properties and add its application field at the input position with [ApplicationFieldCollection.Add](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/applicationfieldcollection/add-method/llms-full.txt). The following handler writes a small form with a text box, a date picker and a check box and saves it as DOCX:

```csharp
private void createContentControlsButton_Click(object sender, EventArgs e)
{
    textControl1.ResetContents();

    textControl1.Selection.Text = "Customer: ";
    PlainTextContentControl customerName = new PlainTextContentControl()
    {
        Title = "Customer name",
        Tag = "CustomerName",
        Text = "Acme Corporation"
    };
    textControl1.ApplicationFields.Add(customerName.ApplicationField);

    textControl1.Selection.Text = "\nOrder date: ";
    DateContentControl orderDate = new DateContentControl()
    {
        Title = "Order date",
        Tag = "OrderDate",
        Date = DateTime.Today
    };
    textControl1.ApplicationFields.Add(orderDate.ApplicationField);

    textControl1.Selection.Text = "\nTerms accepted: ";
    CheckBoxContentControl termsAccepted = new CheckBoxContentControl()
    {
        Title = "Terms accepted",
        Tag = "TermsAccepted",
        Checked = false
    };
    textControl1.ApplicationFields.Add(termsAccepted.ApplicationField);

    // Content controls are kept in DOCX files
    textControl1.Save("order-form.docx", StreamType.WordprocessingML);
}
```

The code works as follows:

- Setting `Selection.Text` inserts text at the input position, and each `Add` inserts the next content control after it.
- [Title](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/title-property/llms-full.txt) and [Tag](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/tag-property/llms-full.txt) are the title and the tag of the content control that MS Word shows and that other applications use to find the control.
- [PlainTextContentControl.Text](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/plaintextcontentcontrol/text-property/llms-full.txt), [DateContentControl.Date](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/datecontentcontrol/date-property/llms-full.txt) and [CheckBoxContentControl.Checked](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/checkboxcontentcontrol/checked-property/llms-full.txt) set the value of each control.

The base class [ContentControlFieldAdapter](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/llms-full.txt) has the properties that all content controls share:

| Property | Contains |
|---|---|
| [Title](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/title-property/llms-full.txt), [Tag](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/tag-property/llms-full.txt) | The title and the tag of the content control |
| [Id](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/id-property/llms-full.txt) | The ID of the content control |
| [ContentEditable](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/contenteditable-property/llms-full.txt), [ContentDeletable](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/contentdeletable-property/llms-full.txt) | Whether the content can be edited and deleted |
| [Placeholder](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/placeholder-property/llms-full.txt) | The placeholder part of the content control |
| [Type](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/contentcontrolfieldadapter/type-property/llms-full.txt) | The type of the content control, as a string |

The six derived classes add the value of their type:

| Class | Value |
|---|---|
| [PlainTextContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/plaintextcontentcontrol/llms-full.txt), [RichTextContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/richtextcontentcontrol/llms-full.txt) | [Text](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/plaintextcontentcontrol/text-property/llms-full.txt) and [Text](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/richtextcontentcontrol/text-property/llms-full.txt), the text of a control for plain or for formatted text |
| [CheckBoxContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/checkboxcontentcontrol/llms-full.txt) | [Checked](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/checkboxcontentcontrol/checked-property/llms-full.txt) |
| [ComboBoxContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/comboboxcontentcontrol/llms-full.txt) | [ListItems](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/comboboxcontentcontrol/listitems-property/llms-full.txt), the entries of a list the user can also type into |
| [DropDownListContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/dropdownlistcontentcontrol/llms-full.txt) | [ListItems](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/dropdownlistcontentcontrol/listitems-property/llms-full.txt), the entries of a list with fixed choices |
| [DateContentControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/datecontentcontrol/llms-full.txt) | [Date](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/datecontentcontrol/date-property/llms-full.txt), [DateFormat](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/datecontentcontrol/dateformat-property/llms-full.txt), [LanguageID](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/datecontentcontrol/languageid-property/llms-full.txt) and [Calendar](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/datecontentcontrol/calendar-property/llms-full.txt) |

To read the title and tag of the content controls of an existing document, load it with `ApplicationFieldFormat.MSWord` and pass each application field to the constructor of the adapter class of its type. The blog article [Working with Content Controls in MS Word Documents using TX Text Control in C#](https://www.textcontrol.com/blog/2024/03/04/working-with-content-controls-in-ms-word-documents-using-tx-text-control-in-c-sharp/) shows both ways of loading, and [Form Field Compatibility: Work with AcroForms, Legacy MS Word Forms, and Content Controls](https://www.textcontrol.com/blog/2024/04/04/form-fields-working-with-acroforms-legacy-ms-word-forms-and-content-controls/) compares the kinds of form fields.

### Read and Change Legacy Form Fields

The legacy form fields of MS Word are application fields with the type names `FORMTEXT`, `FORMCHECKBOX` and `FORMDROPDOWN`. Their adapters are [FormText](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formtext/llms-full.txt), [FormCheckBox](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formcheckbox/llms-full.txt) and [FormDropDown](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formdropdown/llms-full.txt). The following handler loads a Word form, lists every legacy form field with its value and checks all check boxes:

```csharp
private void readLegacyFormFieldsButton_Click(object sender, EventArgs e)
{
    LoadSettings loadSettings = new LoadSettings()
    {
        // Keep legacy form fields as application fields
        ApplicationFieldFormat = ApplicationFieldFormat.MSWord
    };

    textControl1.Load("legacy-form.docx", StreamType.WordprocessingML, loadSettings);

    StringBuilder list = new StringBuilder();

    foreach (ApplicationField field in textControl1.ApplicationFields)
    {
        switch (field.TypeName)
        {
            case "FORMTEXT":
                FormText textBox = new FormText(field);
                list.AppendLine($"{textBox.Name}: \"{textBox.Text}\", at most {textBox.MaxLength} characters");
                break;

            case "FORMCHECKBOX":
                FormCheckBox checkBox = new FormCheckBox(field);
                checkBox.Checked = true;
                list.AppendLine($"{checkBox.Name}: checked");
                break;

            case "FORMDROPDOWN":
                FormDropDown dropDown = new FormDropDown(field);
                list.AppendLine($"{dropDown.Name}: {string.Join(", ", dropDown.ListEntries)}");
                break;
        }
    }

    MessageBox.Show(list.ToString());
}
```

The code works as follows:

- [ApplicationField.TypeName](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/applicationfield/typename-property/llms-full.txt) tells the kind of field, and the matching adapter is created with the field as its parameter.
- [FormFieldAdapter](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formfieldadapter/llms-full.txt), the base class of the three adapters, has the [Name](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formfieldadapter/name-property/llms-full.txt), [Text](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formfieldadapter/text-property/llms-full.txt), [Enabled](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formfieldadapter/enabled-property/llms-full.txt), [HelpText](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formfieldadapter/helptext-property/llms-full.txt) and [StatusText](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formfieldadapter/statustext-property/llms-full.txt) of a form field.
- [FormText.MaxLength](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formtext/maxlength-property/llms-full.txt) limits the length of the entry, and [FormText.Type](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formtext/type-property/llms-full.txt) says whether it takes regular text, a number, a date, the current date or time, or a calculation.
- [FormCheckBox.Checked](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formcheckbox/checked-property/llms-full.txt) changes the check box in the document, and [FormDropDown.ListEntries](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/formdropdown/listentries-property/llms-full.txt) holds the entries of the list.
- The handler needs `using System.Text;` for `StringBuilder`.

Save the document as DOCX afterward to keep the changed values.

### NEXT and NEXTIF Fields

Two more Word fields steer a mail merge rather than hold a value. A `NEXT` field moves on to the next record of the data, so that one copy of a merge block shows two or more records, for example to alternate the color of table rows as [Formatting and Styling](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/styling/llms-full.txt) shows. A `NEXTIF` field does this only when a comparison is true. Users insert both with **Insert Special Field** on the **Reporting** tab, as [Reporting Ribbon and Dialog Boxes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/ribbon-dialogs/llms-full.txt) describes.

In code, [NextField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/nextfield/llms-full.txt) creates and reads a `NEXT` field. The following line inserts one at the input position, for example at the end of the first of two table rows in a merge block:

```csharp
// Continue with the next record of the merge block
textControl1.ApplicationFields.Add(new NextField().ApplicationField);
```

[NextIfField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/nextiffield/llms-full.txt) adds the comparison. [Expression1](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/nextiffield/expression1-property/llms-full.txt) must be the name of a data field for the merge, [Expression2](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/nextiffield/expression2-property/llms-full.txt) is the value it is compared with, and [Operator](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/nextiffield/operator-property/llms-full.txt) the comparison: `Equals`, `NotEqual`, `LessThan`, `GreaterThan`, `GreaterThanOrEqualTo` or `LessThanOrEqualTo`. [Result](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/nextiffield/result-property/llms-full.txt) holds the outcome of the comparison. [DataSourceCulture](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/nextiffield/datasourceculture-property/llms-full.txt) and [MergeCulture](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver-fields/nextiffield/mergeculture-property/llms-full.txt) set the cultures used to compare numbers and to format values; both default to the culture of the current thread.

### DocumentController

The reference of this product also lists [DocumentController](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/documentcontroller/llms-full.txt), with its [FieldAdapterCollection](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol-documentserver/documentcontroller-fieldadaptercollection/llms-full.txt) of field adapters: it handles documents on the server for the legacy ASP.NET Web Forms Document Viewer of TX Text Control .NET Server and isn't needed in a Windows Forms application.

### Next Steps

- [Forms and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/form-fields/llms-full.txt): create forms from TX Text Control form fields and check their values.
- [Fields and Subtext Parts](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/fields/llms-full.txt): text fields, hyperlinks, bookmarks and the other Word fields.
- [Merge Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/fields/llms-full.txt): fill merge fields and form fields with data.
- [Loading Documents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/loading/llms-full.txt): the other load settings of Word documents.

---

## Nearby

- **Previous:** [Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/conditional-instructions/llms-full.txt)
- **Next:** [Mail Merge and Reporting](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/llms-full.txt)
