TX Text Control .NET Server

Remove Method

Method
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 text field from a Text Control document.

Syntax

Remove(TextField)

Removes the specified text field from the Text Control document.

public bool Remove(TextField textField);
ParameterDescription
textField

Specifies the text field to remove.

Remove(TextField, bool)

Removes the specified text field from the Text Control document. The field's visible text remains in the document, when the keepText parameter is set to true.

public bool Remove(TextField textField, bool keepText);
ParameterDescription
textField

Specifies the text field to remove.

keepText

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

Return Value

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

Examples

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

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)
{
    TextField textField = textFieldCollection[1];
    if (textFieldCollection.Remove(textField))
    {
        Console.WriteLine("The item was removed.");
    }
}