TX Text Control .NET for Windows Forms

CanAdd Property

Property
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

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

public bool CanAdd { get; }

Examples

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

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.");
    }
}

Limitations

Read only.