TX Text Control .NET Server

Remove 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

Removes a field of the type ApplicationField from a TX Text Control document.

Syntax

Remove(ApplicationField)

Removes a field of the type ApplicationField including its visible text from a TX Text Control document.

public bool Remove(ApplicationField applicationField);
ParameterDescription
applicationField

Specifies the field to remove.

Remove(ApplicationField, bool)

Removes a field of the type ApplicationField from a TX Text Control document. The visible text is deleted depending on the keepText parameter.

public bool Remove(ApplicationField applicationField, bool keepText);
ParameterDescription
applicationField

Specifies the field to remove.

keepText

If this parameter is set to true, the field is removed without deleting its visible text. Otherwise, the field's text is also deleted.

Return Value

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

Examples

The following example removes a merge field while keeping its current result text in the document.

textControl.Text = "Dear ,";
textControl.InputPosition = new InputPosition(5);
ApplicationFieldCollection fields = textControl.ApplicationFields;
ApplicationField customerField = new(ApplicationFieldFormat.MSWord, "MERGEFIELD", "Customer name", new[] { "CustomerName" }) { ID = 100 };
fields.Add(customerField);
fields.Remove(customerField, true);