TX Text Control has strong document processing capabilities beyond simple text editing. It can simplify the creation and manipulation of tables within documents. This makes it very useful to automate documents like banking statements and reports right within your application.

Users can easily insert tables, modify their structure, adjust row and column sizes, and apply formatting to table cells programmatically. This level of control is crucial for managing financial documents. It helps present structured data clearly and professionally.

This article shows the powerful table features in TX Text Control. It also shows the many ways they can improve your document processing in C#.

The following programming categories are discussed in this article:

Tables - TX Text Control .NET for Windows Forms:

Classes
TXTextControl.Table
TXTextControl.TableBaseCollection
TXTextControl.TableCell
TXTextControl.TableCellCollection
TXTextControl.TableCellFormat
TXTextControl.TableCollection

Adding Tables

Start by inserting a simple table through the provided code snippet using the Table TX Text Control .NET for Windows Forms
TXTextControl Namespace
Table Class
An instance of the Table class represents a table in a Text Control document.
class.

// Set table identifier.
int tableID = 10;
// Add a new table with number of rows and columns.
textControl1.Tables.Add(2, 5, tableID);
// Retrieve the newly added table using the tableID.
TXTextControl.Table table = textControl1.Tables.GetItem(tableID);
view raw test.cs hosted with ❤ by GitHub

Result:

Adding Tables

Formatting TableCells

In any banking statement, it's essential to add header text to tables for displaying transaction details. Handle and format these headers using TableCell TX Text Control .NET for Windows Forms
TXTextControl Namespace
TableCell Class
An instance of the TableCell class represents a single cell of a table in a Text Control document.
and TableCellFormat TX Text Control .NET for Windows Forms
TXTextControl Namespace
TableCellFormat Class
An instance of the TableCellFormat class represents the formatting attributes of a table cell.
classes in TX Text Control.

// Initialize table headers.
string[] headers = { "Date", "Description", "Credit", "Debit", "Balance" };
for (int i = 1; i <= headers.Length; i++)
{
// Assign header text to each cell in the first row.
table.Cells.GetItem(1, i).Text = headers[i - 1];
// Retrieve and select the cell for formatting.
TableCell cell = table.Cells.GetItem(1, i);
cell.Select();
// Center align the text and set it to bold.
textControl1.Selection.ParagraphFormat.Alignment = TXTextControl.HorizontalAlignment.Center;
textControl1.Selection.Bold = true;
// Change the text color.
textControl1.Selection.ForeColor = Color.Navy;
}
view raw test.cs hosted with ❤ by GitHub

Result:

Formatting TableCells

Now that the table headers have content, use the TableCellFormat class to improve their visual appeal by formatting the background color and border width.

// Create a new TableCellFormat object to apply formatting.
TXTextControl.TableCellFormat myCellFormat = new TXTextControl.TableCellFormat();
// Set the background color.
myCellFormat.BackColor = Color.LightGray;
// Specify a bottom border width.
myCellFormat.BottomBorderWidth = 50;
// Apply the formatting.
for (int i = 1; i <= 5; i++)
{
table.Cells.GetItem(1, i).CellFormat = myCellFormat;
}
view raw test.cs hosted with ❤ by GitHub

Result:

Formatting TableCells

Conclusion

Above are a few properties of the TableCellFormat class used for formatting table cells. However, many more are available to customize and automate documents based on your needs. Refer to the image below for further possibilities:

Properties
BackColor
BottomBorderColor
BottomBorderWidth
BottomTextDistance
LeftBorderColor
LeftBorderWidth
LeftTextDistance
NumberFormat
RightBorderColor
RightBorderWidth
RightTextDistance
TextType
TopBorderColor
TopBorderWidth
TopTextDistance
VerticalAlignment