Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to remove merged cells in the column can not pass on the data in the columns that hold Datagrid.con pass on that same data is still Merge cell. anyone know please teach me with. Here is the code I merge all columns cell.

C#
public class GridDecorator
		{
			public static void MergeRows(DataGrid gridView)
			{
			for (int rowIndex = gridView.Items.Count - 2; rowIndex >= 0; rowIndex--)
				{
					DataGridItem row = gridView.Items[rowIndex];
					DataGridItem previousRow = gridView.Items[rowIndex + 1];

					for (int i = 0; i < row.Cells.Count; i++)
					{							
						if (row.Cells[i].Text == previousRow.Cells[i].Text)
						{
					row.Cells[i].RowSpan = eviousRow.Cells[i].RowSpan < 2 ? 2 : 
								previousRow.Cells[i].RowSpan + 1;
							previousRow.Cells[i].Visible = false;
						}						   
														
					}
				}
			}
		}		
<
protected void grdEmployee_PreRender(object sender, System.EventArgs e)
        {
            GridDecorator.MergeRows(grdEmployee);
        }


Display nomar

VB
[IMG]https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpf1/v/t34.0-12/10807134_1510073735912771_856276471_n.jpg?oh=29fcc9f370dd003c51e4dbfbe6561d86&oe=54685F39&p;__gda__=1416058857_e0a47d165095e8a4bcd42da7f130cd59[/IMG]

When I Merge

[IMG]https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpa1/v/t34.0-12/10806900_1510073739246104_499714655_n.jpg?oh=b3ed3642b9a81f58d0d559ce07d6391e&oe=54685201&__gda__=1416056865_b6901eff324666d9d24d856071823026[/IMG]

But I'd like as shown below
[IMG]https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpf1/v/t34.0-12/974437_1510073725912772_949911600_n.jpg?oh=8a524564736a3d7b9e5d8d45455cb7de&oe=54674667&__gda__=1416058362_a84fe8a375c2a571e1edd0fb1705762b[/IMG]
Posted
Updated 16-Nov-14 21:55pm
v7
Comments
Shweta N Mishra 14-Nov-14 3:32am    
Your question is not clear
Member 11226106 14-Nov-14 20:13pm    
This is the normal display data mansion
[IMG]https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpf1/v/t34.0-12/10807134_1510073735912771_856276471_n.jpg?oh=29fcc9f370dd003c51e4dbfbe6561d86&oe=54685F39&p;__gda__=1416058857_e0a47d165095e8a4bcd42da7f130cd59[/IMG]

When I Merge

[IMG]https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpa1/v/t34.0-12/10806900_1510073739246104_499714655_n.jpg?oh=b3ed3642b9a81f58d0d559ce07d6391e&oe=54685201&__gda__=1416056865_b6901eff324666d9d24d856071823026[/IMG]

But I'd like as shown below
[IMG]https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpf1/v/t34.0-12/974437_1510073725912772_949911600_n.jpg?oh=8a524564736a3d7b9e5d8d45455cb7de&oe=54674667&__gda__=1416058362_a84fe8a375c2a571e1edd0fb1705762b[/IMG]

means that the problem of displaying the data from the database to the DataGrid. I have merged cells are all identical cell data including null cells display. h now I want to just merge the cell with the same data being passed is holding the other display null data merge, and the load cell has null value from the database, it will not merg again. I mean it. We're looking for help
These images are not showing on browser. please host somewhere else and post the links here, if you want.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900