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

merge cells

Hi

I have one question on the grid merge cell feature. Please take a look at the spreadsheet attached. I want all the rows merged for the column A. However, for the column B, the merge just apply based on the column A merged range.
So the B2:B3 is merged in one cell, B4:B8 is merged in one cell, thought B2:B8 have the same value. We use the virtual grid. Can it be implmented in essential grid?

Regards,
Hui

mergecellTest.zip

1 Reply

AD Administrator Syncfusion Team October 4, 2006 04:37 AM UTC

Hi Hui,

The VirtualMergeCell browser sample demonstrates the dynamic merge cells. It uses the derived GridControl and the GridModel to handle this task. For more static merge cells, all you have to do, is to the properties that are shown below while going through the work of the deriving classes to override methods in order to implement dynamic merging.

MergeCells refer to the combining of cells which, have either the same values or the same styles. The sample shows you how to merge cells with like values dynamically. The sample fills the first three columns with virtual data in the OnQueryCellInfo. The grid checks which, cells are repeating (OnQueryCanMergeCells determines if cells are to be treated equal) and automatically merges them on demand. You can enable merging rows within a column with.

grid.Model.Options.MergeCellsMode = GridMergeCellsMode.OnDemandCalculation|GridMergeCellsMode.MergeRowsInColumn;

Then you can specify the merge behavior for individual cells. To make merging the default for all cells do this.

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

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

In The VirtualMergeCell browser sample we are filling the first three columns with virtual data in the OnQueryCellInfo. The grid checks which, cells are repeating (OnQueryCanMergeCells determines if cells are to be treated equal) and automatically merges them on demand.Changes in the columns are ignored since the value is always calculated in the OnQueryCellInfo. The other columns are regular cells where you can enter data and save them in the regular grid data object. When you enter the same value in neighboring cells in the same column they will automatically merge. When one value is changed then, they will automatically un-merge. Please refer the MergeCell Browser sample for more details. Below is a path

\Syncfusion\Essential Studio\4.3.0.25\windows\Grid.Windows\Samples\Quick Start\VirtualMergeCell\cs

Thanks,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon