SharpDataGridView OnDataError
时间:2010-08-30 来源:leslie116
protected override void OnDataError(bool displayErrorDialogIfNoHandler, DataGridViewDataErrorEventArgs e)
{
if ((e.Exception) is ConstraintException)
{
//DataGridView view = (DataGridView)sender;
this.Rows[e.RowIndex].ErrorText = e.Exception.Message;
e.Cancel = true;
e.ThrowException = false;
//displayErrorDialogIfNoHandler = false;
}
base.OnDataError(displayErrorDialogIfNoHandler, e);
//MessageBox.Show("Error happened " + e.Context.ToString());
//if (e.Context == DataGridViewDataErrorContexts.Commit)
//{
// MessageBox.Show("Commit error");
//}
//if (e.Context == DataGridViewDataErrorContexts.CurrentCellChange)
//{
// MessageBox.Show("Cell change");
//}
//if (e.Context == DataGridViewDataErrorContexts.Parsing)
//{
// MessageBox.Show("parsing error");
//}
//if (e.Context == DataGridViewDataErrorContexts.LeaveControl)
//{
// MessageBox.Show("leave control error");
//}
//if ((e.Exception) is ConstraintException)
//{
// //DataGridView view = (DataGridView)sender;
// this.Rows[e.RowIndex].ErrorText = "an error";
// this.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "an error";
// e.ThrowException = false;
//}
}