Microsoft Word form fields, such as content controls and legacy form fields, are widely used to create interactive documents for data entry, templates, and workflows. Users can input structured data directly within Word documents with these fields, which are commonly used in contract automation, surveys, and forms.

Building cross-platform .NET applications can be challenging, especially when working with form fields, especially on Linux systems. Fortunately, TX Text Control provides a powerful, consistent API that allows you to import, access, and manipulate both content controls (structured document tags) and legacy form fields in DOCX documents across platforms, including Linux.

What Are MS Word Form Fields?

Microsoft Word supports two main types of form fields:

  • Legacy Form Fields:: These are the basic fields used in older versions of Word, such as text inputs, checkboxes, and dropdowns.
  • Content Controls:: These were introduced in later versions of Word and offer a more structured, XML-based approach to embedding data in documents.

TX Text Control provides seamless support for both formats through a unified API, making it easy to programmatically create, read, and manipulate form fields in your .NET applications.

How to Work with Form Fields in TX Text Control

When loading a document, the ApplicationFieldFormat TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
LoadSettings Class
ApplicationFieldFormat Property
Specifies the format of text fields which are imported.
property can be used for specification of how a field is imported. Three relevant options can be specified when importing fields.

By using MSWordTXFormFields, all legacy and content control form fields are automatically converted into TX Text Control form fields.

Now, let's take a look at a document that contains both content control form fields and older, legacy form fields.

DOCX (Office Open XML) form fields in TX Text Control

Accessing Form Fields

Looping through all fields is simple. We just need to load the document with the specific LoadSettings and access the FormFieldCollection TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
FormFieldCollection Class
An instance of the FormFieldCollection class contains all form fields in a Text Control document represented through objects of the types TextFormField, CheckFormField and SelectionFormField.
.

using TXTextControl;
var loadSettings = new LoadSettings
{
ApplicationFieldFormat = ApplicationFieldFormat.MSWordTXFormFields
};
using var serverTextControl = new ServerTextControl();
serverTextControl.Create();
serverTextControl.Load("document.docx", StreamType.WordprocessingML, loadSettings);
Console.WriteLine("Form Fields in the document:");
foreach (var field in serverTextControl.FormFields)
{
switch (field)
{
case TextFormField textField:
Console.WriteLine($"TextFormField: {textField.Text}");
break;
case CheckFormField checkBox:
Console.WriteLine($"CheckFormField: {checkBox.Checked}");
break;
case DateFormField dateField:
Console.WriteLine($"DateFormField: {dateField.Date}");
break;
case SelectionFormField selectionField:
var selectedItem = selectionField.Items.ElementAtOrDefault(selectionField.SelectedIndex);
Console.WriteLine($"SelectionFormField: {selectedItem}");
break;
}
}
view raw test.cs hosted with ❤ by GitHub

In this example, we load a DOCX document that contains both content control form fields and legacy form fields. The document is loaded with the MSWordTXFormFields setting, which converts all form fields into TX Text Control form fields.

The following results are printed to the console:

Form Fields in the document:
TextFormField: Content Control Text

CheckFormField: True
SelectionFormField: Item2
DateFormField: 5/8/2025 12:00:00 AM
TextFormField: Text1
CheckFormField: False

Both form field types are accessible in the unified form field provided by the TX Text Control.

Conclusion

TX Text Control provides a powerful API for working with form fields in .NET applications, regardless of the platform. By using the MSWordTXFormFields setting, you can easily convert and access both content control and legacy form fields in your documents.