# DocumentLinkCollection.Clear Method

> Removes all document links from a Text Control document.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 13.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 > DocumentLinkCollection.Clear Method
- **739 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/clear-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/clear-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/clear-method/llms-full.txt

---

### Description

Removes all document links from a Text Control document.

### Syntax

```csharp
public void Clear(bool keepText);
```

```vbnet
Public Sub Clear(keepText As Boolean)
```

### Parameters

| Parameter | Description |
|---|---|
| keepText | If this parameter is set to true, all document links are removed without deleting their texts. Otherwise, the texts are also deleted. |

### Examples

The following example works with document links in the current document by using `DocumentLinkCollection.Clear`.

```csharp
textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
DocumentLinkCollection documentLinkCollection = textControl.DocumentLinks;
DocumentTarget target = new("CustomerDetails");
textControl.DocumentTargets.Add(target);
documentLinkCollection.Add(new DocumentLink("View customer details", target) { ID = 100 });

if (documentLinkCollection.Count > 0)
{
    documentLinkCollection.Clear(true);
}
```

```vbnet
textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim documentLinkCollection As DocumentLinkCollection = textControl.DocumentLinks
Dim target As New DocumentTarget("CustomerDetails")
textControl.DocumentTargets.Add(target)
documentLinkCollection.Add(New DocumentLink("View customer details", target) With { .ID = 100 })

If documentLinkCollection.Count > 0 Then
    documentLinkCollection.Clear(True)
End If
```

---

## Nearby

- **Previous:** [DocumentLinkCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/add-method/llms-full.txt)
- **Next:** [DocumentLinkCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/copyto-method/llms-full.txt)
