TX Text Control .NET for WPF

TableCell Class

Class
Namespace
TXTextControl
Package
TXTextControl.TextControl.WPF.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXTextControl.dll
Install
dotnet add package TXTextControl.TextControl.WPF.SDK .NET 8 and later. For .NET Framework, reference TXTextControl.dll from the setup.

Description

An instance of the TableCell class represents a single cell of a table in a Text Control document. It can be obtained from the table's cell collection.

Syntax

public class TableCell

Examples

The following example shows how to handle table cells.

TableCell myCell = myTable.Cells.GetItem(1, 1);
myCell.Width = 2 * 1440; // 2 inches
myCell.Text = "Some sample text";
myCell.Select();

textControl1.Selection.FontSize = 8 * 20; // 8pt
textControl1.Selection.ParagraphFormat.Alignment = HorizontalAlignment.Right;

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

textControl.Tables.Add(3, 3, 10);
Table table = textControl.Tables.GetItem(10);
TableCell tableCell = table.Cells[2, 2];

Members

Properties

PropertyDescription
CellFormatGets or sets the formatting attributes of a table cell. The property's value is an object of the type TableCellFormat.
ColumnGets the table cell's column number.
FormulaGets or sets the table cell's formula. For each table cell a formula can be defined which is used to calculate the cell's text. The formula can contain references to other table cells in the same table. When the text of a referenced cell changes, the cell which references it is automatically updated. The Supported Formula Functions section lists all supported formulas. Cell references can be specified either with the A1 or with the R1C1 notation. The A1 notation specifies a table cell with a column letter and a row number, for example B3 refers to the table cell in the third row and the second column. The R1C1 notation addresses a table cell with a row number and a column number, for example R3C2 refers to the same table cell in the third row and the second column. Relative addresses can be expressed with square brackets, for example R[-3]C[-2]. The numbers inside the square brackets show how many rows or columns the cell is relative to itself. Negative row numbers mean that the referenced cell is above the cell containing the formula. Negative column numbers mean that the referenced cell is to the left of the cell containing the formula. To switch the reference style the FormulaReferenceStyle property can be used. The formula's result is formatted according to the format specified with the TableCellFormat.NumberFormat property.
LengthGets the number of characters in the table cell. If the table cell is merged, the property returns -1.
NameGets or sets the cell's name. Each table cell can have a name, which can be used to store any string data associated with the cell.
PositionGets or sets, in twips, the horizontal position of the cell.
RowGets the table cell's row number.
StartGets the index (one-based) of the first character in the table cell.
TextGets or sets the cell's text.
WidthGets or sets, in twips, the width of the cell.

Methods

MethodDescription
SelectSelects the table cell.