TX Text Control .NET for WPF

Remove Method

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

Description

Removes a document link from a Text Control document.

Syntax

Remove(DocumentLink)

Removes a document link including its visible text from a Text Control document.

public bool Remove(DocumentLink documentLink);
ParameterDescription
documentLink

Specifies the document link to remove.

Remove(DocumentLink, bool)

Removes a document link from a Text Control document. The visible text is deleted depending on the keepText parameter.

public bool Remove(DocumentLink documentLink, bool keepText);
ParameterDescription
documentLink

Specifies the document link to remove.

keepText

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

Return Value

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

Examples

The following example works with document links in the current document by using DocumentLinkCollection.Remove.

textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
DocumentLinkCollection documentLinkCollection = textControl.DocumentLinks;
DocumentTarget target = new("CustomerDetails");
textControl.DocumentTargets.Add(target);
documentLinkCollection.Add(new DocumentLink("View customer details", target) { ID = 100 });

if (documentLinkCollection.Count > 0)
{
    DocumentLink documentLink = documentLinkCollection[1];
    if (documentLinkCollection.Remove(documentLink))
    {
        Console.WriteLine("The item was removed.");
    }
}