TX Text Control .NET for Windows Forms

TableOfContentsCollection Class

Class|Introduced in 29.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXTextControl.dll
Install
dotnet add package TXTextControl.TextControl.WinForms.SDK .NET 8 and later. For .NET Framework, reference TXTextControl.dll from the setup.
Implements
ICollection, IEnumerable

Description

Contains all tables of contents in a certain part of the document. It is a collection of objects of the type TableOfContents. A collection object can be obtained with the TextControl.TablesOfContents, the WPF.TextControl.TablesOfContents, the HeaderFooter.TablesOfContents or the TextFrame.TablesOfContents property. The TableOfContentsCollection class implements the IEnumerable and the ICollection interfaces.

Syntax

public sealed class TableOfContentsCollection : ICollection, IEnumerable

Examples

The following example works with tables of contents in the current document.

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

Members

Properties

PropertyDescription
CountGets the number of elements contained in the collection.
IsSynchronizedReturns true if the collection is designed to be thread safe, otherwise, it returns false.
ItemGets the table of contents with the specified number from the collection. The number must be between 1 and Count. In C# this property is the indexer for the TableOfContentsCollection class.
SyncRootGets an object that can be used to synchronize access to the collection.

Methods

MethodDescription
AddAdds a new table of contents to the document at the current text input position.
CopyToCopies the elements of the collection to an array, starting at a particular index.
GetEnumeratorReturns an enumerator that can be used to iterate through the collection.
GetItemGets a particular table of contents from the collection.
RemoveRemoves a table of contents from the collection including all its text and including all DocumentTargets to where the table's links point.

Enumerations

EnumerationDescription
AddResultSpecifies the result when an existing table of contents has been updated or a new table of contents has been added to the document.

Further Reading

  • Create a Table of Contents in Windows Forms using C# –