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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to merge cells programmatically?

Thread ID:

Created:

Updated:

Platform:

Replies:

149813 Dec 10,2019 02:02 PM UTC Dec 11,2019 09:04 AM UTC UWP 1
loading
Tags: SfRichTextBoxAdv
Trumpledor
Asked On December 10, 2019 02:02 PM UTC

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
          };
          row.Cells.Add(cell);
     }
     table.Rows.Add(row);   
}

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

this.Document.Sections[0].Blocks.Clear();
this.Document.Sections[0].Blocks.Add(table);

... 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");
end.MoveToParagraphend();
this.Selection.Select(beg, end);
this.Focus(FocusState.Programmatic);

Using the Merge Cells command...

this.MergeSelectedCellsCommand.Execute(null);

... 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,
Michael


Premkumar Sundaramoorthy [Syncfusion]
Replied On 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. 
  
Regards, 
Premkumar 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon