We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Is it possible to merge cells programmatically?

Dear Support,

Suppose I create programmatically a table of 3 rows by 2 columns...

TableAdv table = new TableAdv();
for (int i = 0; i < 3; i++)
     TableRowAdv row = new TableAdvRow();
     for (int j = 0; j < 2; j++)
          TableCellAdv cell = new TableCellAdv
               CellFormat = userDefinedCellFormat

... then add it to my SfRichTextBoxAdv control...


... and select a series of cells programmatically, in this case, the cells of the 2nd row...

TextPosition beg = this.Document.GetTextPosition("0;0;1;0;0;0");
TextPosition end = this.Document.GetTextPosition("0;0;1;1;0;0");
this.Selection.Select(beg, end);

Using the Merge Cells command...


... has no effect on the selected cells and so I want to see how those cells, or any combination of contiguous cells that are selected, can be merged programmatically. Is this possible?

Note: If I use commands to create the table and to do the selection, the Merge Cells command works. But everything needs to be done programmatically, so commands can't be used.

Best Regards,

1 Reply

PS Premkumar Sundaramoorthy Syncfusion Team December 11, 2019 09:04 AM UTC

Hi Michael, 
Thank you for using syncfusion support, 
We have prepared the sample to demonstrate how to merge selected cells programmatically. The sample can be downloaded from the below location.   
Please let us know if you need any further assistance. 

Live Chat Icon For mobile
Up arrow icon