TX Text Control .NET for Windows Forms

Add Method

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

Description

Inserts the specified target at the current text input position.

Syntax

public bool Add(DocumentTarget documentTarget);

Parameters

ParameterDescription
documentTarget

Specifies the document target to add.

Return Value

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

Examples

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

textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
DocumentTargetCollection documentTargetCollection = textControl.DocumentTargets;

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