DataGridView数据验证提示错误时,窗口不能正常关闭
DataGridView中的某一单元格的数据不合法时(CellValidating事件中进行验证),
在DataGridView发生错误单元格所在行的前面显示错误提示。
这时,在一个button按下时,想关闭窗体,却不能关闭。
我处理的事件有
①DataError
If e.Context = DataGridViewDataErrorContexts.Commit Then
T_LEGAL_PROCEDURE_DataGridView.Rows(e.RowIndex).ErrorText = e.Exception.ToString
e.Cancel = True
End If
②DefaultValuesNeeded
③CellValidated
Me.T_LEGAL_PROCEDURE_DataGridView.Rows(e.RowIndex).ErrorText = Nothing
④CellValidating 调用验证函数
'If GridValidCodeCheck(T_LEGAL_PROCEDURE_DataGridView.Columns(e.ColumnIndex).Name, e.FormattedValue, e.ColumnIndex, e.RowIndex) = False Then
' e.Cancel = True
' Exit Sub
'End If
⑤RowValidated
Me.T_LEGAL_PROCEDURE_DataGridView.Rows(e.RowIndex).ErrorText = Nothing
⑥RowEnter
大家有碰到过的吗?
请指教