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 Duplicate Cells

Hi, I want to merge Duplicate Cells in different rows in Syncfusion Grid. for Ex : - 100 213 23 23 100 32 4 4 but i need as below 100 213 23 23 32 4 4 but i should able to evaluate the hidden column. thanx in advance. its very urgent too.

11 Replies

AD Administrator Syncfusion Team November 17, 2004 10:38 AM UTC

To use merge cells, you need to set one grid property, and then set a style property in the cells that you want to allow to merge. this.gridControl1.Model.Options.MergeCellsMode = GridMergeCellsMode.OnDemandCalculation|GridMergeCellsMode.MergeRowsInColumn; this.gridControl1.ColStyles[2].MergeCell = GridMergeCellDirection.RowsInColumn; Here is a sample that has both a GridControl and a GridDataBoundGrid in it. The same merge techniques work for each control.

AP Arun Prasath November 18, 2004 01:00 AM UTC

Thanks Mr.Clay its working but it displays value when i am moving mouse over that column which i don''t want. please rectify that too. thanx in advance.

AD Administrator Syncfusion Team November 18, 2004 11:29 AM UTC

Try handling the CurrentCellStartEditing event. In your handler, set e.Cancel = true if the currentcell is part of a merged range.
private void gridControl1_CurrentCellStartEditing(object sender, CancelEventArgs e)
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	GridRangeInfo range;
	if(this.gridControl1.Model.MergeCells.Find(GridMergeCellDirection.RowsInColumn, cc.RowIndex, cc.ColIndex, out range))
		e.Cancel = true;

AP Arun Prasath November 29, 2004 02:59 AM UTC

Hi Clay, But now the problem is while loading the grid for first time it works fine if it has duplicate records for entire life time (i.e) untill closing. If no duplicate records found while loading grid for first time but after evaluating search criteria given by the user and if it returns dupicate records this time its not merging instead it displays all duplicate values. I wanted mergeing Concept at all level. Hope u understand my problem. It is very very important . Thanx in advance. PS: I am doing serach screen in VB.NET where user will enter some value to see records.

AD Administrator Syncfusion Team November 29, 2004 06:25 AM UTC

Instead of setting the gridControl1.Model.Options.MergeCellsMode = GridMergeCellsMode.OnDemandCalculation Or GridMergeCellsMode.MergeRowsInColumn try setting gridControl1.Model.Options.MergeCellsMode = GridMergeCellsMode.BeforeDisplayCalculation Or GridMergeCellsMode.MergeRowsInColumn If thta does not work, if you post a sample showing the problem, we can try to debug the problem here.

AP Arun Prasath November 30, 2004 06:04 AM UTC

Hi Clay, Its working fine now thanks yaar.Now i want to know how to set formulas in Grid.It should be also able to apply for all columns once if i set , something similar to Excel. its also very urgent yaar. Thanx in advance. Arun

AD Administrator Syncfusion Team November 30, 2004 08:36 AM UTC

If you are using our 3.0 code base, there is a simple way to do this. You use row 0 as a place holder for teh current row. this.gridControl1.ColStyles[4].Text = "= A0 + C0"; //row = 0 means use current row This code makes column D hold the sum of column A and column c. You can see this at work in the Syncfusion\Essential Suite\\Windows\Grid.Windows\Samples\Quick Start\GridControlSort sample. In earlier versions you will have to loop through every cell setting teh formula somehow. for(int i = 1; i <= grid.RowCount; ++i) { grid[i, 4].Text = string.Format("= A{0} + C{0}", i); }

AP Arun Prasath November 30, 2004 09:04 AM UTC

Hi Clay, I couldn''t see examples for formula in that path it has only sorting examples. But still i tried using your formula it hasn''t worked fine pls i need proper solution to acheive formula. PS : We are using grid version 1.6. Arun

AD Administrator Syncfusion Team November 30, 2004 10:22 AM UTC

The row 0 place holder code is not in 1.6, but only in 3.0. The sample I referenced only has formula code in 3.0. Not 1.6. In 1.6, you will have to use the string.Format code to add a formula to every cell.

AP Arun Prasath December 1, 2004 04:11 AM UTC

Hi Clay I am getting following Error while i try enter some values in E Column. cast from string "=E1+F1" to type ''Double'' is not valid I ma pointing it to G(7) column. how to handle the situation.

AD Administrator Syncfusion Team December 1, 2004 06:13 AM UTC

The CellValueType for column E (col 5) cannot be typeof(double). Formula cells that hold formulas must have string as the style.CellValueType. This is the default setting, so to have a double there, you probably have explicit code setting style.CellValueType = typeof(double). You should remove this code.

Live Chat Icon For mobile
Up arrow icon