首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于DataGridView_DataError事件的有关问题

2012-06-20 
关于DataGridView_DataError事件的问题DataGridView中调试时候提示---------------------------“DataGridV

关于DataGridView_DataError事件的问题
DataGridView中调试时候提示
--------------------------- 
“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 事件。 
于是我加入代码

C# code
private void classesDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)        {        }

但是那个默认的对话框仍然弹出,请问下要怎么样才能让他变成我自己写的处理,我是新手刚刚学C#请大家说的详细点谢谢

[解决办法]
C# code
try...catch ex as System.ArgumentException  MsgBox(ex.Message.ToString.Trim, MsgBoxStyle.OkOnly, "系統提示!")...
[解决办法]
我以前一个项目就是这样用得
绑定的数据源是数据类型,输入字符会报错,就这样处理得
你可以调试看一下

热点排行