# TableCollection Class

> An instance of the TableCollection class contains all tables of a Text Control document or part of the document represented through objects of the type Table. It can be obtained with the TextControl.Tables, HeaderFooter.Tables or TextFrame.Tables property. The TableCollection class is derived from the TableBaseCollection class and implements therefore the IEnumerable and the ICollection interfaces. Additionally to the properties and methods inherited it implements the following:

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Class
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Inherits:** `TXTextControl.TableBaseCollection`
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > TableCollection Class
- **1927 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/llms-full.txt

---

### Description

An instance of the TableCollection class contains all tables of a Text Control document or part of the document represented through objects of the type [Table](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/table/llms-full.txt). It can be obtained with the [TextControl.Tables](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/tables-property/llms-full.txt), [HeaderFooter.Tables](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/headerfooter/tables-property/llms-full.txt) or [TextFrame.Tables](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textframe/tables-property/llms-full.txt) property. The TableCollection class is derived from the [TableBaseCollection](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablebasecollection/llms-full.txt) class and implements therefore the IEnumerable and the ICollection interfaces. Additionally to the properties and methods inherited it implements the following:

### Syntax

```csharp
public sealed class TableCollection : TableBaseCollection
```

```vbnet
Public NotInheritable Class TableCollection
    Inherits TableBaseCollection
```

### Examples

The following example shows how to handle the table collection.

```csharp
int myTableId = 10;
textControl1.Tables.GridLines = false;

if(textControl1.Tables.CanAdd)
    textControl1.Tables.Add(5, 3, myTableId);

TXTextControl.Table myTable = textControl1.Tables.GetItem(myTableId);
textControl1.Tables.Remove(myTableId);
```

```vbnet
Dim MyTableId As Integer = 10
TextControl1.Tables.GridLines = False

If TextControl1.Tables.CanAdd Then
    TextControl1.Tables.Add(5, 3, MyTableId)
End If

Dim MyTable As TXTextControl.Table = TextControl1.Tables.GetItem(MyTableId)
TextControl1.Tables.Remove(MyTableId)
```

The following example works with tables in the current document.

```csharp
TableCollection tableCollection = textControl.Tables;
tableCollection.Add(3, 3, 10);
```

```vbnet
Dim tableCollection As TableCollection = textControl.Tables
tableCollection.Add(3, 3, 10)
```

---

## In This Section

- [TableCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/add-method/llms-full.txt): Adds a new table at the current text input position.
- [TableCollection.CanAdd Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/canadd-property/llms-full.txt): Gets a value indicating whether a new table can be inserted at the current input position. This property does not check for protected TextFields and/or protected document sections. To perform this use in addition the TextControl.CanEdit property.
- [TableCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/getitem-method/llms-full.txt): Gets the table at the current input position. To get a particular table with a certain identifier use the base class's implementation TableBaseCollection.GetItem.
- [TableCollection.GridLines Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/gridlines-property/llms-full.txt): Gets or sets a value indicating wether table grid lines are shown or not.
- [TableCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/remove-method/llms-full.txt): Removes the table at the current text input position. To remove a particular table with a certain identifier use the base class's implementation TableBaseCollection.Remove.
- [TableCollection.SupportedFormulaFunctions Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/supportedformulafunctions-property/llms-full.txt): Gets a list of all formula functions currently supported. These functions are listed in Supported Formula Functions. For more information how to construct a formula with predefined functions see Using Formulas in Table Cells.
- [TableCollection.SupportedNumberFormats Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/supportednumberformats-property/llms-full.txt): Gets a list of often used number formats for formula results. See Formatting Text by using Number Formats for more information about number format strings.

---

## Nearby

- **Previous:** [TableCellFormat.VerticalAlignment Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecellformat/verticalalignment-property/llms-full.txt)
- **Next:** [TableCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecollection/add-method/llms-full.txt)
