throwing InvalidOperationException
when I changed cell value for update and directly click on menu strip item for open new Winform.
private void dgv_category_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
DataTable dt = new DataTable();
dt = u.operationOnDataBase(sqlquery_selectCategory, 3);
if (dt.Rows.Count > 0)
{
MessageBox.Show("Category Already Exist...");
}
else
{
u.operationOnDataBase(sqlquery_UpdateCategory, 1);
u.SyncMaster("update", "CategoryDetails", 0, Convert.ToInt32(dgv_category[1, e.RowIndex].Value.ToString()));//---------Sync
}
try
{
dgv_category.DataSource = null; //here Throwing exception
u.operationOnDataBase(sqlquery, 3);
dgv_category.DataSource = u.dt;
}
catch (InvalidOperationException)
{
// exception
}
}
Exception- Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.
at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick) at System.Windows.Forms.DataGridView.set_CurrentCell(DataGridViewCell value) at System.Windows.Forms.DataGridView.set_DataSource(Object value)
private void dgv_category_CellEndEdit(object sender, DataGridViewCellEventArgs e) { this.BeginInvoke(new MethodInvoker(() => }
– Mam