# TableOfContentsCollection Class

> 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.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Class
- **Introduced:** 29.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.Core.SDK` (assembly `TXTextControl.Core.dll`, from the private NuGet feed or Text Control Offline Packages)
- **Package:** `TXTextControl.TextControl.ASP.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET Server > Reference > TXTextControl > TableOfContentsCollection Class
- **1294 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/llms-full.txt

---

### Description

Contains all tables of contents in a certain part of the document. It is a collection of objects of the type [TableOfContents](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontents/llms-full.txt). A collection object can be obtained with the [TextControl.TablesOfContents](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/tablesofcontents-property/llms-full.txt), the [WPF.TextControl.TablesOfContents](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/tablesofcontents-property/llms-full.txt), the [HeaderFooter.TablesOfContents](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/headerfooter/tablesofcontents-property/llms-full.txt) or the [TextFrame.TablesOfContents](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/textframe/tablesofcontents-property/llms-full.txt) property. The TableOfContentsCollection class implements the IEnumerable and the ICollection interfaces.

### Syntax

```csharp
public sealed class TableOfContentsCollection : ICollection, IEnumerable
```

```vbnet
Public NotInheritable Class TableOfContentsCollection
    Implements ICollection, IEnumerable
```

### Examples

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

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

```vbnet
textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim tableOfContentsCollection As TableOfContentsCollection = textControl.TablesOfContents
tableOfContentsCollection.Add(New TableOfContents(1, 3) With { .Name = "Contents", .ID = 100 })
```

---

## In This Section

- [TableOfContentsCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/add-method/llms-full.txt): Adds a new table of contents to the document at the current text input position.
- [TableOfContentsCollection.AddResult Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/addresult-enumeration/llms-full.txt): Specifies the result when an existing table of contents has been updated or a new table of contents has been added to the document.
- [TableOfContentsCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/copyto-method/llms-full.txt): Copies the elements of the collection to an array, starting at a particular index.
- [TableOfContentsCollection.Count Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/count-property/llms-full.txt): Gets the number of elements contained in the collection.
- [TableOfContentsCollection.GetEnumerator Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/getenumerator-method/llms-full.txt): Returns an enumerator that can be used to iterate through the collection.
- [TableOfContentsCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/getitem-method/llms-full.txt): Gets a particular table of contents from the collection.
- [TableOfContentsCollection.IsSynchronized Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/issynchronized-property/llms-full.txt): Returns true if the collection is designed to be thread safe, otherwise, it returns false.
- [TableOfContentsCollection.Item Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/item-property/llms-full.txt): Gets 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.
- [TableOfContentsCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/remove-method/llms-full.txt): Removes a table of contents from the collection including all its text and including all DocumentTargets to where the table's links point.
- [TableOfContentsCollection.SyncRoot Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/syncroot-property/llms-full.txt): Gets an object that can be used to synchronize access to the collection.

---

## Nearby

- **Previous:** [TableOfContents.Update Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontents/update-method/llms-full.txt)
- **Next:** [TableOfContentsCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tableofcontentscollection/add-method/llms-full.txt)
