officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-table-dot-mergecells-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-tablecell-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-tablecell-x29.md
Merges the cells in the specified range into a single cell.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
void MergeCells(
TableCell mergeFrom,
TableCell mergeTo
)
Sub MergeCells(
mergeFrom As TableCell,
mergeTo As TableCell
)
| Name | Type | Description |
|---|---|---|
| mergeFrom | TableCell |
A TableCell that marks one end of the merged range.
| | mergeTo | TableCell |
A TableCell that marks the opposite end of the merged range.
|
All cells that fall within a table range marked by specified cells (including them) are merged into a single cell. The order in which cells are specified as method arguments does not matter.
This code snippet performs the following:
Document document = server.Document;
Table table = document.Tables.Create(document.Range.Start, 6, 8);
table.BeginUpdate();
table.MergeCells(table[2, 1], table[5, 1]);
table.MergeCells(table[2, 3], table[2, 7]);
table.EndUpdate();
Dim document As Document = server.Document
Dim table As Table = document.Tables.Create(document.Range.Start, 6, 8)
table.BeginUpdate()
table.MergeCells(table(2, 1), table(5, 1))
table.MergeCells(table(2, 3), table(2, 7))
table.EndUpdate()
The following code snippets (auto-collected from DevExpress Examples) contain references to the MergeCells(TableCell, TableCell) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-richedit-tables-simple-example/CS/TablesSimpleExample/Form1.cs#L57
// Merge cells
table.MergeCells(table[4, 2], table[4, 3]);
table.MergeCells(table[6, 2], table[6, 3]);
word-document-api-examples/CS/CodeExamples/TablesActions.cs#L101
// Merge table cells.
table.MergeCells(table[1, 1], table[2, 1]);
winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Table.cs#L228
table.BeginUpdate();
table.MergeCells(table[2, 1], table[5, 1]);
table.MergeCells(table[2, 3], table[2, 7]);
wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/TableActions.cs#L232
table.BeginUpdate();
table.MergeCells(table[2, 1], table[5, 1]);
table.MergeCells(table[2, 3], table[2, 7]);
word-document-api-table-examples/CS/Program.cs#L77
//Merge cells
table.MergeCells(table[4, 1], table[4, 2]);
table.MergeCells(table[6, 1], table[6, 2]);
winforms-richedit-tables-simple-example/VB/TablesSimpleExample/Form1.vb#L48
' Merge cells
table.MergeCells(table(4, 2), table(4, 3))
table.MergeCells(table(6, 2), table(6, 3))
word-document-api-examples/VB/CodeExamples/TablesActions.vb#L92
' Merge table cells.
table.MergeCells(table(1, 1), table(2, 1))
#End Region ' #CreateFixedTable
winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Table.vb#L203
table.BeginUpdate()
table.MergeCells(table(2, 1), table(5, 1))
table.MergeCells(table(2, 3), table(2, 7))
wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/TableActions.vb#L205
table.BeginUpdate()
table.MergeCells(table(2, 1), table(5, 1))
table.MergeCells(table(2, 3), table(2, 7))
word-document-api-table-examples/VB/Program.vb#L60
'Merge cells
table.MergeCells(table(4, 1), table(4, 2))
table.MergeCells(table(6, 1), table(6, 2))
See Also