# FormFieldCollection

The `FormFieldCollection` class holds a collection of [FormField](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/formfields) instances, assigned to the [AcroForm](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/acroform) of the document. The collection exposes useful [properties](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/formfieldcollection#properties) and [methods](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/formfieldcollection#methods) that allow you to access, add, or remove the form fields in a document.

## Properties

The `FormFieldCollection` class exposes an indexer and a `Count` property. Use the indexer to get a [FormField](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/formfields) instance by its name, or use `Count` to get the number of all form fields in the document.

## Methods

The following methods allow you to construct a form field and add it to the collection. Each method accepts a string parameter representing the unique name of the form field. The generated field is returned from the method so you can customize it.

* `AddPushButton()`: Creates a [PushButton](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/pushbuttonfield) field and adds it to the collection. Returns the created field.

* `AddCheckBox()`: Creates a [CheckBox](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/checkboxfield) field and adds it to the collection. Returns the created field.

* `AddRadioButton()`: Creates a [RadioButton](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/radiobuttonfield) field and adds it to the collection. Returns the created field.

* `AddCombTextBox()`: Creates a [CombTextBox](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/combtextboxfield) field and adds it to the collection. Returns the created field.

* `AddTextBox()`: Creates a [TextBox](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/textboxfield) field and adds it to the collection. Returns the created field.

* `AddComboBox()`: Creates a [ComboBox](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/comboboxfield) field and adds it to the collection. Returns the created field.

* `AddListBox()`: Creates a [ListBox](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/listboxfield) field and adds it to the collection. Returns the created field.

* `AddSignature()`: Creates a [Signature](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/signaturefield) field and adds it to the collection. Returns the created field.

The following example shows how to use the previous methods to generate a form field and add it to the collection.

**Create a Form Field**

```C#
CombTextBoxField comb = document.AcroForm.FormFields.AddCombTextBox("comb");
comb.MaxLengthOfInputCharacters = 10;
comb.Value = "0123456789";
```

You can also use the following methods to modify the collection of form fields in the document [AcroForm](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/acroform):

* `Add()`: Accepts a parameter of type [FormField](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/formfields) and inserts it to the collection.

* `Remove()`: Accepts a parameter of type [FormField](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/formfields) and removes it from the collection.

* `Contains()`: Accepts a string representing the form field name. Returns `true` when a field with such a name is present in the collection, otherwise `false`.

**Use the Methods of FormFieldCollection**

```C#
string fieldName = "my-field-name";
if (document.AcroForm.FormFields.Contains(fieldName))
{
    document.AcroForm.FormFields.Remove(document.AcroForm.FormFields[fieldName]);
}
```

## See Also

* [FormField](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/form-fields/formfields)
* [PDF Annotation Widgets](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/annotations/widgets)
* [AcroForm](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/interactive-forms/acroform)
* [Extracting Data from PDF Form Fields Using RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/extract-pdf-form-fields-data-radpdfprocessing)
