TX Text Control .NET for WPF

Remove Method

Method|Introduced in 23.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.WPF.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

Description

Removes a subtextpart from the collection including all its nested subtextparts.

Syntax

public bool Remove(SubTextPart subTextPart, bool keepText, bool keepNested);

Parameters

ParameterDescription
subTextPart

Specifies the subtextpart to remove.

keepText

If this parameter is set to true, the subtextpart is removed without deleting its visible text. Otherwise, the visible text is also removed.

keepNested

If this parameter is set to true, nested subtextparts are preserved. When the keepText parameter is set to false, this parameter is ignored.

Return Value

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

Examples

The following example removes a region marker while retaining both its text and nested regions.

textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
SubTextPartCollection parts = textControl.SubTextParts;
SubTextPart customer = new("CustomerName", 10) { Data = @"{""category"":""customer""}" };
parts.Add(customer);
parts.Remove(customer, true, true);