Gridcontrol How to check or get all Duplicate Cell Values in a Column
2 Replies
SIGN IN To post a reply.
Hi,
I have been trying to check duplicate cell values in a column before saving.
Using Linq works with normal windows grid but with synfusion doesn't work.
Dim distinctsrno = From row As DataGridViewRow In dataGridViewDetailSheet.Rows Where Not row.Cells(11).Value = "" Select CStr(row.Cells(11).Value) Distinct
getting error :
Error BC36593 Expression of type 'GridModelRowColOperations' is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider.
|
//Event Subscription
this.gridControl1.DrawCellDisplayText += new GridDrawCellDisplayTextEventHandler(grid_DrawCellDisplayText);
//Event Customization
private void grid_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
//To add particular column(1) values to list
if (e.ColIndex == 1 && e.RowIndex > 0 )
{
list1.Add(e.DisplayText);
}
}
//Load duplicate values to listbox
private void button1_Click(object sender, EventArgs e)
{
if (list1.Count > 0)
{
var duplicates = list1.GroupBy(x => x).Where(g => g.Count() > 1).Select(y => y.Key).ToList();
listBox1.DataSource = duplicates;
}
} |