TX Text Control .NET for WPF

Add Method

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

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