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
close icon

Suppress duplicate value in a column

Is it possible to suppress duplicate value occured in a column? For example, I am having a situation to display delivery number details. Here the delivery number will appear only once but the details are more. Ex: Delivery No. LineItem Qty 000690 1 10 000690 2 20 . . In this case, Delivery number has to disply only once in the first column. Pls help on this. Thanks Rabeek

3 Replies

AD Administrator Syncfusion Team August 12, 2004 10:29 AM UTC

We refer to this as merging cells (if I understand what you want). 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. Here is code for a GridControl. 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. Similar merge techniques work for each control.


RA Rabeek Ahamed August 12, 2004 12:42 PM UTC

Thanks Clay. This is what i want. But i am having a problem... The value is display when we select the empty cell. Can we avoid that? can we display the grid lines in that merge cell? Thanks


AD Administrator Syncfusion Team August 12, 2004 02:28 PM UTC

If you want to keep the grid lines and avoid editing the empty cells, then I woul dnot use mergecells. Instead I would try using PrepareViewStyleInfo and set the text empty there, and handle CurrentCellStartEditing event, and prevent the editing there. If you comment out the merge cell code in teh GridDataBoundGrid in teh sample from above, and subscribe to those two events with these handlers, the sample seems to do what you described.
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.ColIndex == 2
		&& e.RowIndex > 1 
		&& this.gridDataBoundGrid1[e.RowIndex, e.ColIndex].Text ==
		this.gridDataBoundGrid1[e.RowIndex - 1, e.ColIndex].Text)
	{
		e.Style.Text = "";
	}
}

private void gridDataBoundGrid1_CurrentCellStartEditing(object sender, CancelEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.ColIndex == 2
		&& cc.RowIndex > 1 
		&& this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].Text ==
		this.gridDataBoundGrid1[cc.RowIndex - 1, cc.ColIndex].Text)
	{
		e.Cancel = true;
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon