# ApplicationFieldCollection.Add Method

> Inserts a new object of the type ApplicationField at the current input position.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 14.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > ApplicationFieldCollection.Add Method
- **706 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/applicationfieldcollection/add-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/applicationfieldcollection/add-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/applicationfieldcollection/add-method/llms-full.txt

---

### Description

Inserts a new object of the type [ApplicationField](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/applicationfield/llms-full.txt) at the current input position.

### Syntax

```csharp
public bool Add(ApplicationField applicationField);
```

```vbnet
Public Function Add(applicationField As ApplicationField) As Boolean
```

### Parameters

| Parameter | Description |
|---|---|
| applicationField | Specifies the field to add. |

### Return Value

The return value is true, if the field could be added. Otherwise it is false.

### Examples

The following example inserts a Word-compatible `MERGEFIELD` for a customer's name at the current input position.

```csharp
textControl.Text = "Dear ,";
textControl.InputPosition = new InputPosition(5);

ApplicationField customerField = new(
    ApplicationFieldFormat.MSWord,
    "MERGEFIELD",
    "Customer name",
    new[] { "CustomerName" });

if (!textControl.ApplicationFields.Add(customerField))
{
    throw new InvalidOperationException("The merge field could not be inserted.");
}
```

```vbnet
textControl.Text = "Dear ,"
textControl.InputPosition = New InputPosition(5)

Dim customerField As New ApplicationField(
    ApplicationFieldFormat.MSWord,
    "MERGEFIELD",
    "Customer name",
    New String() { "CustomerName" })

If Not textControl.ApplicationFields.Add(customerField) Then
    Throw New InvalidOperationException("The merge field could not be inserted.")
End If
```

---

## Nearby

- **Previous:** [ApplicationFieldCollection Class](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/applicationfieldcollection/llms-full.txt)
- **Next:** [ApplicationFieldCollection.Clear Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/applicationfieldcollection/clear-method/llms-full.txt)
