# TextFieldCollection Class

> An instance of the TextFieldCollection class contains all standard text fields in a Text Control document or part of the document represented through objects of the type TextField. An instance of this class can be obtained with the TextControl.TextFields, HeaderFooter.TextFields or TextFrame.TextFields property. The TextFieldCollection class implements the IEnumerable and the ICollection interface. For more information see the technical article Text Fields and Hypertext Links.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Class
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WinForms.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Inherits:** `TXTextControl.TextFieldCollectionBase`
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl > TextFieldCollection Class
- **1443 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfieldcollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfieldcollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfieldcollection/llms-full.txt

---

### Description

An instance of the TextFieldCollection class contains all standard text fields in a Text Control document or part of the document represented through objects of the type [TextField](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfield/llms-full.txt). An instance of this class can be obtained with the [TextControl.TextFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/textfields-property/llms-full.txt), [HeaderFooter.TextFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/headerfooter/textfields-property/llms-full.txt) or [TextFrame.TextFields](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textframe/textfields-property/llms-full.txt) property. The TextFieldCollection class implements the IEnumerable and the ICollection interface. For more information see the technical article Text Fields and Hypertext Links.

### Syntax

```csharp
public sealed class TextFieldCollection : TextFieldCollectionBase
```

```vbnet
Public NotInheritable Class TextFieldCollection
    Inherits TextFieldCollectionBase
```

### Examples

The following example works with text fields in the current document.

```csharp
textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
TextFieldCollection textFieldCollection = textControl.TextFields;
textFieldCollection.Add(new ApplicationField(ApplicationFieldFormat.MSWord, "MERGEFIELD", "Customer name", new[] { "CustomerName" }) { ID = 100 });
```

```vbnet
textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim textFieldCollection As TextFieldCollection = textControl.TextFields
textFieldCollection.Add(New ApplicationField(ApplicationFieldFormat.MSWord, "MERGEFIELD", "Customer name", New String() { "CustomerName" }) With { .ID = 100 })
```

---

## In This Section

- [TextFieldCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfieldcollection/add-method/llms-full.txt): Inserts a new standard text field at the current input position.
- [TextFieldCollection.Clear Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfieldcollection/clear-method/llms-full.txt): Removes all text fields from a Text Control document.
- [TextFieldCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfieldcollection/copyto-method/llms-full.txt): Copies the elements of the collection to an array, starting at a particular index.
- [TextFieldCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfieldcollection/getitem-method/llms-full.txt): Gets a particular text field from the collection.
- [TextFieldCollection.Item Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfieldcollection/item-property/llms-full.txt): Gets the field with the specified number from the collection. The number must be between 1 and Count. In C# this property is the indexer for the TextFieldCollection class.
- [TextFieldCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfieldcollection/remove-method/llms-full.txt): Removes a text field from a Text Control document.

---

## Nearby

- **Previous:** [TextField.Text Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfield/text-property/llms-full.txt)
- **Next:** [TextFieldCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textfieldcollection/add-method/llms-full.txt)
