# Forms and Conditional Instructions

> Process fillable forms in Windows Forms code: form field types, protection, value events, conditional instructions, reading values and flattening forms.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for Windows Forms > Document Processing > Forms and Conditional Instructions
- **1051 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/form-fields/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/form-fields/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/form-fields/llms-full.txt

---

A booking request, an order form or a checklist becomes a fillable form when its blanks are form fields: text boxes, check boxes, drop-down lists and date pickers. In a Windows Forms application, the `TextControl` is both the designer and the form: your code inserts the fields, protects the document so that users can only fill them out, reacts to every value they enter and checks the values with conditional instructions, rules stored in the document itself.

Each step below is explained in full on the page it links to. Forms are available in the Enterprise edition, as [Editions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/overview/editions/llms-full.txt) lists. Filling form fields from data is described in [Merge Form Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/fields/#merge-form-fields).

### Form Field Types

All form fields derive from [FormField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/formfield/llms-full.txt) and are kept in [TextControl.FormFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/formfields-property/llms-full.txt), the form fields of the whole document: [TextFormField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textformfield/llms-full.txt), [CheckFormField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/checkformfield/llms-full.txt), [SelectionFormField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/selectionformfield/llms-full.txt) and [DateFormField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/llms-full.txt). [Form Field Types](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/#form-field-types) describes what the user does with each of them.

![TX Text Control Words with the Form Fields ribbon tab and a booking request form whose drop-down list of accommodations is open.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-winforms/form-fields-tab-booking.231799ef.webp)

### Create a Form

[FormFieldCollection.Add](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/formfieldcollection/add-method/llms-full.txt) inserts a form field at the input position and returns `true` if it was inserted. [Insert Form Fields in Code](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/#insert-form-fields-in-code) builds a booking form with one field of each type and explains the constructors; besides the overload with a width, the [DateFormField constructor](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/dateformfield/constructor/llms-full.txt) also takes the preset date and the width.

### Protect the Form

Until the document is protected, the user can edit all text around the fields. [DocumentPermissions.ReadOnly](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documentpermissions/readonly-property/llms-full.txt), [AllowEditingFormFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documentpermissions/alloweditingformfields-property/llms-full.txt) and the `EditMode` `ReadAndSelect` turn it into a form, as [Let Users Fill Out the Form](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/#let-users-fill-out-the-form) shows. [Document Protection and User Permissions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/security/document-protection/llms-full.txt) describes the other permissions and passwords.

### React to Values the User Enters

`FormFieldTextChanged`, `FormFieldCheckChanged`, `FormFieldSelectionChanged` and `FormFieldDateChanged` report the values the user enters, each with the changed form field in its event data. [Read the Values](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/#read-the-values) lists the events and reads the value of each field type: `Text`, `Checked`, `SelectedIndex` or `Date`, which is `null` while the date field is empty.

### Check Values With Conditional Instructions

A *conditional instruction* is a rule stored in the document: when its conditions are fulfilled, its instructions change form fields, for example mark a value as invalid, disable a field or set a new value. TX Text Control evaluates the rules while the user fills out the protected form, so the form checks itself without code in your application. [Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/conditional-instructions/llms-full.txt) describes every condition and instruction, in the dialog box and in C#, and builds the rules of a complete booking request form.

### Read and Flatten the Values

To archive a filled form so that nobody can change it, *flatten* it: remove the form fields with `GetTextFields(TextFieldType.FormFields).Clear(true)` and keep their text. [Exporting Interactive and Flattened Forms](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/pdf/forms/exporting/llms-full.txt) flattens all or some fields of a form, and [PDF Forms](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/pdf/forms/llms-full.txt) reads the filled PDF forms that come back from users.

### Next Steps

- [Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/conditional-instructions/llms-full.txt): every kind of condition and instruction, with a complete example.
- [Form Fields and Conditional Instructions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-editor/form-fields/llms-full.txt): design forms with the ribbon and in code.
- [Document Protection and User Permissions](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/security/document-protection/llms-full.txt): passwords and permissions of protected documents.
- [Merge Fields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/mail-merge/fields/llms-full.txt): fill form fields from data.
- [Fields and Subtext Parts](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/fields/llms-full.txt): the other kinds of fields.

---

## Nearby

- **Previous:** [Fields and Subtext Parts](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/fields/llms-full.txt)
- **Next:** [Comments and Tracked Changes](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/document-processing/comments-changes/llms-full.txt)
