TX Text Control .NET for WPF

Clear 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

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

Syntax

public void Clear(bool keepText);

Parameters

ParameterDescription
keepText

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

Examples

The following example removes every application field while preserving each field's visible text.

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.Clear(true);