Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial

TableCell

TableCell element is a BlockContainer element and defines a cell of content within a Table. It contains Block elements such as Paragraph and Table.

Inserting a TableCell

You can use the code snippet from Example 1 to create a TableCell and add it in a TableRow.

Example 1: Create a TableCell object and add it to a TableRow

TableCell cell = new TableCell(document); 
row.Cells.Add(cell); 

To create a TableCell and add it in the document tree in the same time, you can use the AddTableCell() method.

Example 2: Create a TableCell and add it to a TableRow in the same time

TableRow row = table.Rows.AddTableRow(); 
TableCell cell = row.Cells.AddTableCell(); 

Modifying a TableCell

The TableCell element exposes several properties that allow you to customize its layout. A part of these properties are Style properties and some of the values represent a themable object.

Style properties are properties that can be inherited from a style. For more information about styles see this article.

Themable objects are objects that can be inherited from a theme. For more information about themes check this article.

  • Properties: Retrieves all TableCellProperties. For more information read this article.

  • Row: Represents the parent TableRow of the cell.

  • Table: Represents the parent Table of the cell.

  • Borders: Specifies the borders of the cell. This is a Style property.

  • Shading: Represents the shading applied to the cell. It is a composite object and is read-only. You can obtain the following properties from it:

    • BackgroundColor: Specifies the background color for the shading. This is a Style property. The value is themable object.

    • PatternColor: Specifies the pattern color for the shading. This is a Style property. The value is themable object.

    • Pattern: Specifies the pattern which is used to lay the pattern color over the background color for the shading. This is a Style property.

  • Padding: Specifies the padding of the cell. This is a Style property.

  • ColumnSpan: Indicates the total number of columns that the TableCell spans within a TableRow. This property cannot be derived from a style.

  • RowSpan: Specifies the total number of rows that the TableCell spans within a Table. This property cannot be derived from a style.

  • IgnoreCellMarkerInRowHeightCalculation: Specifies whether cell marker is ignored when row height is calculated. This property cannot be derived from a style.

  • CanWrapContent: Specifies whether the content can be wrapped during the table layout. This property cannot be derived from a style.

  • PreferredWidth: Specifies the preferred width of the cell. This property cannot be derived from a style.

  • VerticalAlignment: Specifies the vertical alignment of the cell's content. This property cannot be derived from a style.

  • TextDirection: Specifies the direction of the text in the cell. It could have one of the values of the TextDirection enumeration. This property cannot be derived from a style.

  • GridColumnIndex: Represents the column index of the cell in the table grid.

  • GridRowIndex: Represents the row index of the cell in the table grid.

Operating with a TableCell

Add a Paragraph to a TableCell

Example 3 demonstrates how to add a Paragraph to a TableCell.

Example 3: Add a paragraph to a TableCell

Paragraph paragraph = cell.Blocks.AddParagraph(); 

Through the BlockCollection property of the TableCell element you can add a Table or any other BlockBase element.

See Also

In this article