TX Text Control .NET Server

Add Method

Method|Introduced in 14.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.Core.SDK as TXTextControl.Core.dll from the private NuGet feed or Text Control Offline Packages
Also in
TXTextControl.TextControl.ASP.SDK as TXTextControl.dll

Description

Inserts a new object of the type ApplicationField at the current input position.

Syntax

public bool Add(ApplicationField applicationField);

Parameters

ParameterDescription
applicationField

Specifies the field to add.

Return Value

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

Examples

The following example inserts a Word-compatible MERGEFIELD for a customer's name at the current input position.

textControl.Text = "Dear ,";
textControl.InputPosition = new InputPosition(5);

ApplicationField customerField = new(
    ApplicationFieldFormat.MSWord,
    "MERGEFIELD",
    "Customer name",
    new[] { "CustomerName" });

if (!textControl.ApplicationFields.Add(customerField))
{
    throw new InvalidOperationException("The merge field could not be inserted.");
}