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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Virtual merge cells

Thread ID:





75143 Jul 14,2008 08:15 PM UTC Jul 16,2008 10:43 AM UTC WinForms 3
Tags: GridControl
Asked On July 14, 2008 08:15 PM UTC


I want to merge cells in my grid. I have gone through VirtualMergeCells sample and have done in a similar way. But the issue is, OnQueryCanMergeCells is not getting called for all columns. It is just being called for first column. So only the first colum,n is getting merged and in all other columns, data is repeated. Briefly these are my grid settings:

Cols.FrozenCount = 1;

BaseStylesMap["Header"].StyleInfo.Trimming = StringTrimming.EllipsisCharacter;

GridStyleInfo standardStyle = BaseStylesMap["Standard"].StyleInfo;
standardStyle.MergeCell = GridMergeCellDirection.RowsInColumn;

GridStyleInfo rowHeaderStyle = BaseStylesMap["Row Header"].StyleInfo;
rowHeaderStyle.MergeCell = GridMergeCellDirection.RowsInColumn;

BaseStylesMap.Modified = false;

// Other options
Model.Options.MergeCellsMode = GridMergeCellsMode.BeforeDisplayCalculation | GridMergeCellsMode.MergeRowsInColumn;

Model.Options.ExcelLikeCurrentCell = false;
Model.Options.ExcelLikeSelectionFrame = false;

Model.Options.ResizeRowsBehavior = GridResizeCellsBehavior.ResizeSingle;
Model.Options.ControllerOptions = GridControllerOptions.ResizeCells;

CellModels.Add("details", new RevisionDetailsCellModel(Model));

protected override void OnQueryCanMergeCells(GridQueryCanMergeCellsEventArgs e)
if (e.Handled || RowCount == 0)

GridStyleInfoIdentity identity1 = e.Style1.CellIdentity;
GridStyleInfoIdentity identity2 = e.Style2.CellIdentity;
if (identity1.ColIndex <= 0)

e.Handled = true;
e.Result = false;

if (identity1.ColIndex <= 3 &&
identity1.RowIndex > 0 &&
identity2.RowIndex <= RowCount)
e.Result = CanMergeCells(identity1.RowIndex, identity2.RowIndex);

There are totally four columns and we try to merge the values of first three columns. The above method is not getting call for column index > 1. Kindly let me know how to resolve this.

Syncfuison version:


Replied On July 15, 2008 12:07 PM UTC

Can someone kindly respond? Thanks.


Replied On July 15, 2008 03:38 PM UTC


QueryMergeCells is not working as expected. The method OnQueryCanMergCells is not getting called for all rows in a single column. Also, it is not fired for all columns. Kindly explain the logic behind this. Thanks.


Jisha Joy [Syncfusion]
Replied On July 16, 2008 10:43 AM UTC

Hi Kiran,

Please use the following code snippets and let me know if this helps:

protected override void OnQueryCanMergeCells(GridQueryCanMergeCellsEventArgs e)
base.OnQueryCanMergeCells (e);

if (!e.Handled)
GridStyleInfoIdentity id1 = e.Style1.CellIdentity;
GridStyleInfoIdentity id2 = e.Style2.CellIdentity;

if (id1.ColIndex <= 3)
e.Result = CanMergeCells(e.Style1, e.Style2);
e.Handled = true;


public bool CanMergeCells(GridStyleInfo style1, GridStyleInfo style2)
GridStyleInfoIdentity id1 = style1.CellIdentity;
GridStyleInfoIdentity id2 = style2.CellIdentity;

if (id1.RowIndex < 1 || id2.RowIndex < 1)
return false;

return style1.Text != "" && style1.Text == style2.Text;

We appreciate your interest in Syncfusion Products.



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