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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to find duplicates in grid

Thread ID:





72008 Feb 26,2008 03:52 PM UTC Feb 28,2008 06:52 PM UTC WinForms 1
Tags: GridControl
Asked On February 26, 2008 03:52 PM UTC

I try to find a way, to format cells in gridcontrol to become red if there is duplicate values.
In excel conditional formatting I do:
=CountIf(A:A, A1)>1

It means check entire column A for occurences of value in Cell A1 and count them. if count > 1 then set cell background color in i.e. red.And then I copy this formula in all the cells in current column.

Please help.

Administrator [Syncfusion]
Replied On February 28, 2008 06:52 PM UTC

Hi Luka,

Thank you for your interest in Syncfusion products.

You can achieve this task using GridFindReplaceDialog class, instead of using the formula. Please refer the code below for more details.

GridFindReplaceDialogSink fr;
private void buttonAdv1_Click(object sender, EventArgs e)
string SearchedText = string.Empty;
GridFindReplaceEventArgs fre;
GridFindReplaceDialog frDialog = GridFindReplaceDialog.Instance;
GridFindTextOptions options = GridFindTextOptions.MatchCase | GridFindTextOptions.MatchWholeCell;
object locInfo = GridRangeInfo.Table();
int rowIndex, colIndex;

fr = new GridFindReplaceDialogSink(this.gridControl1);

frDialog.SetState(this.fr, "", false);
frDialog.TopMost = false;
frDialog.TextSearched = SearchedText;
frDialog.TextSearched = "ABC";

GridCurrentCell cc = this.gridControl1.CurrentCell;
this.gridControl1.Model.Selections.Add(GridRangeInfo.Cell(cc.RowIndex, cc.ColIndex));
GridRangeInfo selRange = GridRangeInfo.Cells(1, 1, gridControl1.RowCount, gridControl1.ColCount);
int startTop = selRange.Top;
int startLeft = selRange.Left;
while (GridFindReplaceDialogSink.GetNextCell(selRange, ref startTop, ref startLeft, false, false))
GridStyleInfo style = gridControl1[startTop, startLeft];
GridCellRendererBase renderer = gridControl1.CellRenderers[style.CellType];
if (renderer.FindText(this.gridControl1[1, 1].Text, startTop, startLeft, options, true))
gridControl1.CurrentCell.GetCurrentCell(out rowIndex, out colIndex);
gridControl1[rowIndex, colIndex].BackColor = Color.Orange;

Please refer the code below that implements this task.

When you click "Select Duplication of First Cell' button in the attached sample, then it will highlight the duplicate value of the first cell.

Please let me know if this helps.



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

or the page will be automatically redirected to 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