Remove Method
- Namespace
TXTextControl
- Package
TXTextControl.asTextControl. Core. SDK TXTextControl.from the private NuGet feed or Text Control Offline PackagesCore. dll
- Also in
TXTextControl.asTextControl. ASP. SDK 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);Public Function Remove(textField As TextField) As Boolean| Parameter | Description |
|---|---|
| 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);Public Function Remove(textField As TextField, keepText As Boolean) As Boolean| Parameter | Description |
|---|---|
| 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.");
}
}textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim textFieldCollection As TextFieldCollection = textControl.TextFields
textFieldCollection.Add(New ApplicationField(ApplicationFieldFormat.MSWord, "MERGEFIELD", "Customer name", New String() { "CustomerName" }) With { .ID = 100 })
If textFieldCollection.Count > 0 Then
Dim textField As TextField = textFieldCollection.Item(1)
If textFieldCollection.Remove(textField) Then
Console.WriteLine("The item was removed.")
End If
End If