# DocumentTargetCollection.CanAdd Property

> Gets a value indicating whether a new document target can be inserted at the current text input position. It is true if a target can be inserted, otherwise it is false.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Property
- **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 > DocumentTargetCollection.CanAdd Property
- **733 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documenttargetcollection/canadd-property/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documenttargetcollection/canadd-property/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documenttargetcollection/canadd-property/llms-full.txt

---

### Description

Gets a value indicating whether a new document target can be inserted at the current text input position. It is true if a target can be inserted, otherwise it is false.

### Syntax

```csharp
public bool CanAdd { get; }
```

```vbnet
Public ReadOnly Property CanAdd As Boolean
```

### Examples

The following example works with document targets in the current document by using `DocumentTargetCollection.CanAdd`.

```csharp
textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
DocumentTargetCollection documentTargetCollection = textControl.DocumentTargets;
documentTargetCollection.Add(new DocumentTarget("CustomerDetails") { ID = 100 });

if (documentTargetCollection.CanAdd)
{
    if (!documentTargetCollection.Add(new DocumentTarget("CustomerName")))
    {
        throw new InvalidOperationException("The item could not be inserted.");
    }
}
```

```vbnet
textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim documentTargetCollection As DocumentTargetCollection = textControl.DocumentTargets
documentTargetCollection.Add(New DocumentTarget("CustomerDetails") With { .ID = 100 })

If documentTargetCollection.CanAdd Then
    If Not documentTargetCollection.Add(New DocumentTarget("CustomerName")) Then
        Throw New InvalidOperationException("The item could not be inserted.")
    End If
End If
```

### Limitations

Read only.

---

## Nearby

- **Previous:** [DocumentTargetCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documenttargetcollection/add-method/llms-full.txt)
- **Next:** [DocumentTargetCollection.Clear Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/documenttargetcollection/clear-method/llms-full.txt)
