# TableCellCollection Class

> An instance of the TableCellCollection class contains all cells of a table in a Text Control document represented through TableCell objects. It can be obtained with the Table.Cells property. The TableCellCollection class implements the IEnumerable and the ICollection interfaces.

- **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.TablePartCollection`
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > TableCellCollection Class
- **1443 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecellcollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecellcollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecellcollection/llms-full.txt

---

### Description

An instance of the TableCellCollection class contains all cells of a table in a Text Control document represented through [TableCell](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecell/llms-full.txt) objects. It can be obtained with the [Table.Cells](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/table/cells-property/llms-full.txt) property. The TableCellCollection class implements the IEnumerable and the ICollection interfaces.

### Syntax

```csharp
public sealed class TableCellCollection : TablePartCollection
```

```vbnet
Public NotInheritable Class TableCellCollection
    Inherits TablePartCollection
```

### Examples

The following example shows how to iterate over the table cell collection.

```csharp
foreach (TXTextControl.TableCell myCell in myTable.Cells)
{
    string myRow = myCell.Row.ToString();
    string myCol = myCell.Column.ToString();
    string myText = myCell.Text;
    Console.WriteLine("({0},{1}): {2}", myRow, myCol, myText);
}
```

```vbnet
For Each MyCell As TXTextControl.TableCell In MyTable.Cells
    Dim MyRow As String = MyCell.Row.ToString()
    Dim MyCol As String = MyCell.Column.ToString()
    Dim MyText As String = MyCell.Text
    Console.WriteLine("({0},{1}): {2}", MyRow, MyCol, MyText)
Next
```

The following example creates a small report table and works with its structure.

```csharp
textControl.Tables.Add(3, 3, 10);
Table table = textControl.Tables.GetItem(10);
TableCellCollection tableCellCollection = table.Cells;
```

```vbnet
textControl.Tables.Add(3, 3, 10)
Dim table As Table = textControl.Tables.GetItem(10)
Dim tableCellCollection As TableCellCollection = table.Cells
```

---

## In This Section

- [TableCellCollection.CanRemove Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecellcollection/canremove-property/llms-full.txt): Gets a value indicating whether table cells can be removed. Table cells can be removed, if either the current text input position is in a table, or if a part of a table is selected.
- [TableCellCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecellcollection/copyto-method/llms-full.txt): Copies the elements of the collection to an array, starting at a particular index.
- [TableCellCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecellcollection/getitem-method/llms-full.txt): Gets a particular table cell from the collection.
- [TableCellCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecellcollection/remove-method/llms-full.txt): Removes the table cell at the current text input position or all selected table cells when a text selection exists.

---

## Nearby

- **Previous:** [TableCell.Width Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecell/width-property/llms-full.txt)
- **Next:** [TableCellCollection.CanRemove Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/tablecellcollection/canremove-property/llms-full.txt)
