Hi Josip,
Thanks for using Syncfusion products.
We have analyzed your provided code part. In your code part, you have tried to check the duplicate value by iterating through records collection . If you edit the cell value, the record value has updated in RecordsCollection so the MessageBox(“Exists”) appears even if it has a different value. In order to overcome this scenario, you can use the RowIndex property in CurrentRecordContextChange event. Please refer to the below code example,
Code example,
this.gridGroupingControl1.CurrentRecordContextChange += gridGroupingControl1_CurrentRecordContextChange;
void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
if (e.Action == Syncfusion.Grouping.CurrentRecordAction.EndEditCalled)
{
Record rec = e.Record as Record;
int newIndex = rec.GetRowIndex();
string myCode = Convert.ToString(rec.GetValue("Country"));
if (this.gridGroupingControl1.Table.CurrentRecord != null )
{
foreach (Record r in e.Table.Records)
{
int rowindex = r.GetRowIndex();
string existValue = r.GetValue(this.gridGroupingControl1.TableDescriptor.Fields["Country"]).ToString();
if (myCode == existValue && rowindex != newIndex)
{
MessageBox.Show("Exists!");
e.Cancel = true;
break;
}
}
}
}
} |
Regards,
Mohanraj G