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

Suppress duplicate value in a column

Thread ID:





17574 Aug 12,2004 10:15 AM UTC Aug 12,2004 02:28 PM UTC WinForms 3
Tags: GridControl
Rabeek Ahamed
Asked On August 12, 2004 10:15 AM UTC

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

Administrator [Syncfusion]
Replied On 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.

Rabeek Ahamed
Replied On 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

Administrator [Syncfusion]
Replied On 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;


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon