2016-06-12 32 views
0

我想隐藏默认的datagridview错误对话框。 我把代码中的此事件处理程序:dataGridView默认错误对话框句柄

 this.dataGridView2.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(dataGridView2_DataError); 


    private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e) 
    { 
     //empty so it doesn't show anything 
    } 

但仍当我尝试这一点,并留下datagridview的单元格为空(删除一切从它),它告诉我,错误对话框。

截图错误:

enter image description here

+1

我们能否假设你的名字是正确的,并确实将一个事件连接到两个DGV? – TaW

+0

@TaW哦,我错过了它,并敲我的头,为什么它不隐藏对话框.. – Shaharyar

+0

哦,我现在得到它。我迷上了dgv1的事件,并在dgv2上测试了它。谢谢。 – DoLoop

回答

3

加以处理和Cancel事件:

private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e) 
{ 
    e.Cancel = true; 
} 
+0

仍然一样。 DataGridView默认对话框仍然显示。 – DoLoop

+0

你可以附加截图吗? – Shaharyar

+0

已编辑。抬头。 – DoLoop

1

尝试使用此代码来处理事件:

private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e) 
{ 
    e.Cancel = true; 
}