本文轉載:http://blog.csdn.net/szstephenzhou/article/details/7834725
--關於DataGridView_DataError事件的問題
/********************************************************************************
*主題:關於DataGridView_DataError事件的問題 *說明:本文是個人學習的一些筆記和個人愚見
* 有很多地方你可能覺得有異議,歡迎一起討論
*作者:Stephenzhou(阿蒙)
*日期: 2012.08.6
*Mail:szstephenzhou@163.com
*另外:轉載請著名出處。
**********************************************************************************/
“DataGridView 默認錯誤”對話框
---------------------------
DataGridView 中發生以下異常:
System.ArgumentException: 不能將列“CQUESTION_ID”設置為空。請改用 DBNull。
在 System.Data.DataRow.set_Item(DataColumn column, Object value)
在 System.Data.DataRowView.SetColumnValue(DataColumn column, Object value)
在 System.Data.DataColumnPropertyDescriptor.SetValue(Object component, Object value)
在 System.Windows.Forms.DataGridView.DataGridViewDataConnection.PushValue(Int32 boundColumnIndex, Int32 columnIndex, Int32 rowIndex, Object value)
要替換此默認對話框,請處理 DataError 事件。
只需要選擇datagridview中的
private void classesDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
就可以了