# DocumentLinkCollection.Add Method

> Inserts a new document link at the current input position.

- **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 > DocumentLinkCollection.Add Method
- **651 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/add-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/add-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/add-method/llms-full.txt

---

### Description

Inserts a new document link at the current input position.

### Syntax

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

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

### Parameters

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

### Return Value

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

### Examples

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

```csharp
textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
DocumentLinkCollection documentLinkCollection = textControl.DocumentLinks;

if (!documentLinkCollection.Add(new DocumentLink("Quarterly results", new DocumentTarget("CustomerName"))))
{
    throw new InvalidOperationException("The item could not be inserted.");
}
```

```vbnet
textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim documentLinkCollection As DocumentLinkCollection = textControl.DocumentLinks

If Not documentLinkCollection.Add(New DocumentLink("Quarterly results", New DocumentTarget("CustomerName"))) Then
    Throw New InvalidOperationException("The item could not be inserted.")
End If
```

---

## Nearby

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