Gridcontrol How to check or get all Duplicate Cell Values in a Column

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.



2 Replies 1 reply marked as answer

NI Nilofer May 6, 2021 05:35 AM UTC

any one please? any way out ? 


BT Balamurugan Thirumalaikumar Syncfusion Team May 6, 2021 01:20 PM UTC

Hi Nilofer, 

Thank you for contacting Syncfusion support. 

We have checked your query “Gridcontrol How to check or get all Duplicate Cell Values in a Column” at our end. We regret know you that as per the current implementation of GridControl(grid.Model.Rows) does not have Linq query support. In order to achieve your requirement we suggest you to get the specific column values in a list and find the duplicate values from that list. You can refer the following code snippet for your reference. 

Code Snippet 
//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; 
} 
} 

We have attached the tested sample for your reference and you can download the same from the following location. 

If you want to use Linq support for records you can refer our SfDataGrid(Sfdatagrid.View.Records) control which support the linq query. 

You can refer following forum for your reference. 

Please let us know if you would require any other assistance. we will be happy to assist you. 

Regards, 
Balamurugan Thirumalaikumar

Marked as answer
Loader.
Up arrow icon