Skip to main content
All docs
V25.2
  • Table.MergeCells(TableCell, TableCell) Method

    Merges two adjacent table cells into one cell.

    Namespace: DevExpress.Docs.Presentation

    Assembly: DevExpress.Docs.Presentation.v25.2.dll

    NuGet Package: DevExpress.Docs.Presentation

    Declaration

    public void MergeCells(
        TableCell tableCell1,
        TableCell tableCell2
    )

    Parameters

    Name Type Description
    tableCell1 TableCell

    The first table cell to merge.

    tableCell2 TableCell

    The second table cell to merge.

    Remarks

    Call the Table.MergeCells method to merge a rectangular range of table cells. The first cell in the method parameters specifies the start of the range, and the second specifies the end of the range. After the cells are merged, the Presentation API performs the following steps:

    • The first cell’s ColumnSpan or RowSpan property is increased by the corresponding number of columns or rows.
    • Text paragraphs of merged cells are appended to the first cell Paragraphs collection.
    • The TextArea property of merged cells is set to null.
    • The merged cells’ TableCell.IsMergedVertically or TableCell.IsMergedHorizontally property is set to true depending on the position of merged cells.

    The following code snippet merges two cells in a table:

    DevExpress Presentation API - Tables - Merge Cells

    using DevExpress.Docs.Presentation;
    
    namespace PresentationApiSample;
    
    public class Program {
        public static void Main(string[] _) {
            //...
    
            // Create a 3x3 table (rows x columns) and add it as a shape to the slide
            Table table = new Table(3, 3);
            slide.Shapes.Add(table);
    
            for (int row = 0; row < 3; row++) {
                for (int column = 0; column < 3; column++) {
                    table[row, column].TextArea.Text = $"({row}, {column})";
                }
            }
    
            table.MergeCells(table[0, 0], table[0, 1]);
    
        }
    }
    
    See Also