Quick Tip: Merging Cells in Tables
Cell merging is a very easy task using TX Text Control. The method MergeCells of the Table object merges all selected table cells in a table. In order to select the desired table cells, the Select method can be used. Adjacent cells can be merged horizontally, vertically and both: Horizontal: Vertical: Block: The following code shows how to use the Select method to select a block of cells from row 1 to row 2 and column 2 to column 3:

Cell merging is a very easy task using TX Text Control. The method MergeCells of the Table object merges all selected table cells in a table.
In order to select the desired table cells, the Select method can be used. Adjacent cells can be merged horizontally, vertically and both:
Horizontal:
Vertical:
Block:
The following code shows how to use the Select method to select a block of cells from row 1 to row 2 and column 2 to column 3:
textControl1.Tables.Add(3, 6, 10);
Table table = textControl1.Tables.GetItem(10);
table.Select(1, 2, 2, 3);
table.MergeCells();
Also See
This post references the following in the documentation:
- TXText
Control. Table Class - TXText
Control. Table. Merge Cells Method - TXText
Control. Table. Select Method
Windows Forms
Text Control combines the power of a reporting tool and an easy-to-use WYSIWYG word processor - fully programmable and embeddable in your Windows Forms application. TX Text Control .NET for Windows Forms is a royalty-free, fully programmable rich edit control that offers developers a broad range of word processing features in a reusable component for Visual Studio.
Related Posts
Inserting MergeBlocks with the DataSourceManager and Applying Table Styles in C#
This article shows how to insert MergeBlocks with the DataSourceManager and how to apply table styles to those tables. The article uses the DocumentServer class to insert MergeBlocks with the…
Useful Tricks for Working with Tables
When you are working with complex and long tables, it can be useful to know if a table is broken up across multiple pages. These code snippets will help you with various table related tasks.
Generating Hierarchical Tables from JSON Data in .NET C#
Using TX Text Control, you can generate complex hierarchical tables directly from JSON data. This article explains the code and logic behind it.
Extension Method: Converting Tables to Tabs in C#
When you export documents to formats that don't support tables, such as ANSI text, you can convert those tables to tabs. This article describes how to convert a table object to tabs using a C#…
Formatting Numbers in Table Cells
Table cell text can be interpreted as plain text or as a number with an associated number format. This article explains how to use this format and gives examples for various string formatters.