# DocumentLinkCollection Class

> An instance of the DocumentLinkCollection class contains all links in a Text Control document that point to targets in the same document. An instance of this class can be obtained with the TextControl.DocumentLinks property. The DocumentLinkCollection class implements the IEnumerable and the ICollection interfaces. Document links are represented through the DocumentLink class. For more information see the technical article Text Fields and Hypertext Links.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Class
- **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
- **Inherits:** `TXTextControl.TextFieldCollectionBase`
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > DocumentLinkCollection Class
- **1411 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/llms-full.txt

---

### Description

An instance of the DocumentLinkCollection class contains all links in a Text Control document that point to targets in the same document. An instance of this class can be obtained with the [TextControl.DocumentLinks](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/documentlinks-property/llms-full.txt) property. The DocumentLinkCollection class implements the IEnumerable and the ICollection interfaces. Document links are represented through the [DocumentLink](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlink/llms-full.txt) class. For more information see the technical article Text Fields and Hypertext Links.

### Syntax

```csharp
public sealed class DocumentLinkCollection : TextFieldCollectionBase
```

```vbnet
Public NotInheritable Class DocumentLinkCollection
    Inherits TextFieldCollectionBase
```

### Examples

The following example works with document links in the current document.

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

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

---

## In This Section

- [DocumentLinkCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/add-method/llms-full.txt): Inserts a new document link at the current input position.
- [DocumentLinkCollection.Clear Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/clear-method/llms-full.txt): Removes all document links from a Text Control document.
- [DocumentLinkCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/copyto-method/llms-full.txt): Copies the elements of the collection to an array, starting at a particular index.
- [DocumentLinkCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/getitem-method/llms-full.txt): Gets a particular document link from the collection.
- [DocumentLinkCollection.Item Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/item-property/llms-full.txt): Gets the field with the specified number from the collection. The number must be between 1 and Count. In C# this property is the indexer for the DocumentLinkCollection class.
- [DocumentLinkCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/remove-method/llms-full.txt): Removes a document link from a Text Control document.

---

## Nearby

- **Previous:** [DocumentLink.DocumentTarget Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlink/documenttarget-property/llms-full.txt)
- **Next:** [DocumentLinkCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/documentlinkcollection/add-method/llms-full.txt)
