# TableRowCollection Class

> An instance of the TableRowCollection class contains all rows of a table in a Text Control document represented through objects of the type TableRow. It can be obtained with the Table.Rows property. The TableRowCollection class implements the IEnumerable and the ICollection interfaces.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Class
- **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
- **Inherits:** `TXTextControl.TablePartCollection`
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET Server > Reference > TXTextControl > TableRowCollection Class
- **1458 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerowcollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerowcollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerowcollection/llms-full.txt

---

### Description

An instance of the TableRowCollection class contains all rows of a table in a Text Control document represented through objects of the type [TableRow](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerow/llms-full.txt). It can be obtained with the [Table.Rows](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/table/rows-property/llms-full.txt) property. The TableRowCollection class implements the IEnumerable and the ICollection interfaces.

### Syntax

```csharp
public sealed class TableRowCollection : TablePartCollection
```

```vbnet
Public NotInheritable Class TableRowCollection
    Inherits TablePartCollection
```

### Examples

The following example shows how to handle the table row collection.

```csharp
int myLastRow = myTable.Rows.Count;
TXTextControl.TableRow myRow = myTable.Rows.GetItem(myLastRow);
myRow.Select();

if(myTable.Rows.CanRemove)
    myTable.Rows.Remove();
```

```vbnet
Dim MyLastRow As Integer = myTable.Rows.Count
Dim MyRow As TXTextControl.TableRow = MyTable.Rows.GetItem(MyLastRow)
MyRow.Select()

If MyTable.Rows.CanRemove Then
    MyTable.Rows.Remove()
End If
```

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);
TableRowCollection tableRowCollection = table.Rows;
```

```vbnet
textControl.Tables.Add(3, 3, 10)
Dim table As Table = textControl.Tables.GetItem(10)
Dim tableRowCollection As TableRowCollection = table.Rows
```

---

## In This Section

- [TableRowCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerowcollection/add-method/llms-full.txt): Adds new table rows at the current text input position.
- [TableRowCollection.CanAdd Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerowcollection/canadd-property/llms-full.txt): Gets a value indicating whether a new row 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.
- [TableRowCollection.CanRemove Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerowcollection/canremove-property/llms-full.txt): Gets a value indicating whether selected rows can be removed.
- [TableRowCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerowcollection/copyto-method/llms-full.txt): Copies the elements of the collection to an array, starting at a particular index.
- [TableRowCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerowcollection/getitem-method/llms-full.txt): Gets a particular table row from the collection.
- [TableRowCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerowcollection/remove-method/llms-full.txt): Removes the selected table rows or the row at the current text input position.

---

## Nearby

- **Previous:** [TableRow.Select Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerow/select-method/llms-full.txt)
- **Next:** [TableRowCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/tablerowcollection/add-method/llms-full.txt)
