I have double click event in DataGridView like below :
private void gridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
// put something here to cancel the edit
Form dialogForm = new dialogContainerForm(username);
dialogForm.ShowDialog(this);
}
When this double click fired, it will call another form, and when this child form closed, it will load the grid :
public void callWhenChildClick(List<string> codes)
{
//some code here
Grid_Load();
}
I have cell validating which always fired when this Grid_Load() called :
private void gridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
string code = e.FormattedValue.ToString();
string headerText = gridView.Columns[e.ColumnIndex].HeaderText;
if (!headerText.Equals("No. Transaksi")) return;
if (string.IsNullOrEmpty(code))
{
MessageBox.Show("No. Transaksi tidak boleh kosong!");
e.Cancel = true;
}
}
How to ignore this cell validating just for this case Grid_Load()? Or is there any function to cancel the edit and ignore validating when the cell double clicked?
gridView.CellValidating -= gridView_CellValidatingbefore the call to Grid_Load and thengridView.CellValidating += gridView_CellValidatingafter it to reset it - JayV