Remove Method
- Namespace
TXTextControl
- Package
TXTextControl.asTextControl. WPF. SDK TXTextControl.from the private NuGet feed or Text Control Offline Packagesdll
Description
Removes a subtextpart from the collection including all its nested subtextparts.
Syntax
public bool Remove(SubTextPart subTextPart, bool keepText, bool keepNested);Public Function Remove(subTextPart As SubTextPart, keepText As Boolean, keepNested As Boolean) As BooleanParameters
| Parameter | Description |
|---|---|
| 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);textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim parts As SubTextPartCollection = textControl.SubTextParts
Dim customer As New SubTextPart("CustomerName", 10) With { .Data = "{""category"":""customer""}" }
parts.Add(customer)
parts.Remove(customer, True, True)