TX Text Control .NET for Windows Forms

Remove Method

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

Description

Removes a table of contents from the collection including all its text and including all DocumentTargets to where the table's links point.

Syntax

public bool Remove(TableOfContents tableOfContent);

Parameters

ParameterDescription
tableOfContent

Specifies the table of contents to remove.

Return Value

The return value is true, if the table of contents could be removed. Otherwise, it is false.

Examples

The following example works with tables of contents in the current document by using TableOfContentsCollection.Remove.

textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
TableOfContentsCollection tableOfContentsCollection = textControl.TablesOfContents;
tableOfContentsCollection.Add(new TableOfContents(1, 3) { Name = "Contents", ID = 100 });

if (tableOfContentsCollection.Count > 0)
{
    TableOfContents tableOfContents = tableOfContentsCollection[1];
    if (tableOfContentsCollection.Remove(tableOfContents))
    {
        Console.WriteLine("The item was removed.");
    }
}