This article is obsolete. The field adapter classes have been implemented in the DocumentServer namespace directly:

TXTextControl.DocumentServer.Fields.FieldAdapter class TX Text Control .NET for Windows Forms
DocumentServer.Fields Namespace
FieldAdapter Class
The abstract FieldAdapter class is the base class of all special DocumentServer field adapters.

The sample code is usable and is migrated to the new integrated classes.

In Microsoft Word, Content Controls are controls that can be added and customized for use in documents and templates. Those controls provide properties and settings that can be used to automate documents.

When loading a document in the Office Open XML format, Content Controls are available through the ApplicationFieldCollection and its ApplicationField objects.

The Parameters property contains the pure Office Open XML data of those fields.

The TXTextControl.DocumentServer.Fields namespace already provides field adapter for merge and form fields. Now, we published complete adapter classes for the following content controls:

  • RichTextContentControl
  • PlainTextContentControl
  • CheckBoxContentControl
  • ComboBoxContentControl
  • DateContentControl
  • DropDownContentControl

Using the adapter classes, you can create new content control fields or manipulate content control fields without any knowledge of the specific Office Open XML format.

Those classes extend the existing namespace TXTextControl.DocumentServer.Fields:

In order to create a new CheckBoxContentControl, simply create a new adapter field and add its ApplicationField to TextControl:

CheckBoxContentControl checkbox = new CheckBoxContentControl();
checkbox.Checked = true;

textControl1.ApplicationFields.Add(checkbox.ApplicationField);

To manipulate an existing Content Control field, the adapter field class can be created with the existing ApplicationField in the constructor:

foreach (ApplicationField field in textControl1.ApplicationFields)
{
    Type type = ContentControlFieldAdapter.GetContentControlType(field);

    // based on the type, create a new ContentControl object and
    // display some field information in a MessageBox
    switch (type.Name)
    {
        case "RichTextContentControl":
            RichTextContentControl rtb = new RichTextContentControl(field);

            MessageBox.Show(
                "RichTextContentControl:\r\nText: " + rtb.Text + "\r\n" +
                "Title: " + rtb.Title + "\r\n" +
                "Tag: " + rtb.Tag + "\r\n");
            break;
        // ...
    }
}

Download the sample from GitHub and test it on your own.