# TextFieldCollection.Remove Method

> Removes a text field from a Text Control document.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **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 > TextFieldCollection.Remove Method
- **1133 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textfieldcollection/remove-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textfieldcollection/remove-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textfieldcollection/remove-method/llms-full.txt

---

### Description

Removes a text field from a Text Control document.

### Syntax

#### Remove(TextField)

Removes the specified text field from the Text Control document.

```csharp
public bool Remove(TextField textField);
```

```vbnet
Public Function Remove(textField As TextField) As Boolean
```

| Parameter | Description |
|---|---|
| textField | Specifies the text field to remove. |

#### Remove(TextField, bool)

Removes the specified text field from the Text Control document. The field's visible text remains in the document, when the keepText parameter is set to true.

```csharp
public bool Remove(TextField textField, bool keepText);
```

```vbnet
Public Function Remove(textField As TextField, keepText As Boolean) As Boolean
```

| Parameter | Description |
|---|---|
| textField | Specifies the text field to remove. |
| keepText | If this parameter is set to true, the field is removed without deleting its text. Otherwise, the field's text is also deleted. |

### Return Value

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

### Examples

The following example works with text fields in the current document by using `TextFieldCollection.Remove`.

```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 });

if (textFieldCollection.Count > 0)
{
    TextField textField = textFieldCollection[1];
    if (textFieldCollection.Remove(textField))
    {
        Console.WriteLine("The item was removed.");
    }
}
```

```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 })

If textFieldCollection.Count > 0 Then
    Dim textField As TextField = textFieldCollection.Item(1)
    If textFieldCollection.Remove(textField) Then
        Console.WriteLine("The item was removed.")
    End If
End If
```

---

## Nearby

- **Previous:** [TextFieldCollection.Item Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textfieldcollection/item-property/llms-full.txt)
- **Next:** [TextFieldCollectionBase Class](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textfieldcollectionbase/llms-full.txt)
