TX Text Control .NET Server

Clear Method

Method|Introduced in 13.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 all text fields from a Text Control document.

Syntax

public void Clear(bool keepText);

Parameters

ParameterDescription
keepText

If this parameter is set to true, all text fields are removed without deleting their texts. Otherwise, the texts are also deleted.

Examples

The following example works with text fields in the current document by using TextFieldCollection.Clear.

textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
TextFieldCollection textFieldCollection = textControl.TextFields;
textFieldCollection.Add(new ApplicationField(ApplicationFieldFormat.MSWord, "MERGEFIELD", "Customer name", new[] { "CustomerName" }) { ID = 100 });

if (textFieldCollection.Count > 0)
{
    textFieldCollection.Clear(true);
}