# DocumentLinkCollection.Remove Method

> Removes a document link from a Text Control document.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Method
- **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
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl > DocumentLinkCollection.Remove Method
- **1160 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documentlinkcollection/remove-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documentlinkcollection/remove-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documentlinkcollection/remove-method/llms-full.txt

---

### Description

Removes a document link from a Text Control document.

### Syntax

#### Remove(DocumentLink)

Removes a document link including its visible text from a Text Control document.

```csharp
public bool Remove(DocumentLink documentLink);
```

```vbnet
Public Function Remove(documentLink As DocumentLink) As Boolean
```

| Parameter | Description |
|---|---|
| documentLink | Specifies the document link to remove. |

#### Remove(DocumentLink, bool)

Removes a document link from a Text Control document. The visible text is deleted depending on the keepText parameter.

```csharp
public bool Remove(DocumentLink documentLink, bool keepText);
```

```vbnet
Public Function Remove(documentLink As DocumentLink, keepText As Boolean) As Boolean
```

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

### Return Value

The return value is true, if the document link could be removed. Otherwise it is false.

### Examples

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

```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)
{
    DocumentLink documentLink = documentLinkCollection[1];
    if (documentLinkCollection.Remove(documentLink))
    {
        Console.WriteLine("The item was removed.");
    }
}
```

```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
    Dim documentLink As DocumentLink = documentLinkCollection.Item(1)
    If documentLinkCollection.Remove(documentLink) Then
        Console.WriteLine("The item was removed.")
    End If
End If
```

---

## Nearby

- **Previous:** [DocumentLinkCollection.Item Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documentlinkcollection/item-property/llms-full.txt)
- **Next:** [DocumentLinkEventArgs Class](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documentlinkeventargs/llms-full.txt)
