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

Virtual merge cells

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hi,

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)
{
base.OnQueryCanMergeCells(e);
if (e.Handled || RowCount == 0)
return;

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

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: 3.201.1.0

Thanks
Kiran





Faltu
Replied On July 15, 2008 12:07 PM UTC

Hi,
Can someone kindly respond? Thanks.

Regards
Kiran




Faltu
Replied On July 15, 2008 03:38 PM UTC

Hi,

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.

Regards
Kiran


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.

Regards,
Jisha



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.

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

;