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

merging cells at different rows and columns

Hi,
I am using grid grouping,and I need to merge two cells at different row and at different columns.
ex.
I have five colums c1,c2,c3,c4,c5 and 10 rows from r1-r10.
Now at row no r1 I need to merge c1 and c2 showing only c1 content but c3,c4,c5 will be showing there content.similarly at row r3 I need to merge c3 and c4 showing c3 content,rest of the colums will be showing there content.This coulld happen at any row and any columns depending on the no of columns.At the same time I need to format the content and font of the cells.


1 Reply

JS Jeba S Syncfusion Team August 9, 2007 07:25 AM UTC

Hi ejaz,

Thank you for your details.

You can use the CoveredCells collection in the grid to merge cells at different rows and columns by passing the Cells/Cell, Cols/Col

and Rows/Row in GridRangeInfo.

Please refer this code snippets:

this.gridGroupingControl1.TableModel.CoveredRanges.Add(GridRangeInfo.Cells(4, 1, 4, 2));
this.gridGroupingControl1.TableModel.CoveredRanges.Add(GridRangeInfo.Cells(6, 3, 6, 4));


You can format the covered cells by handling the QueryCellStyleInfo event and set the required styles.

void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if ((e.TableCellIdentity.RowIndex == 4 && e.TableCellIdentity.ColIndex == 1)
||(e.TableCellIdentity.RowIndex == 6 && e.TableCellIdentity.ColIndex == 3))
{
e.Style.Font.Bold = true;
e.Style.Font.Facename = "Arial";
e.Style.Font.Size = 12;
e.Style.BackColor = Color.Pink;
}
}


Please refer the sample which illustrates the above said feature:
http://websamples.syncfusion.com/samples/Grid.Windows/F67076/main.htm

Thank you for using Syncfusion Products.

Best Regards,
Jeba.

Loader.
Live Chat Icon For mobile
Up arrow icon