dataGridView默认错误对话框句柄 [英] dataGridView default error dialog handle

查看:120
本文介绍了dataGridView默认错误对话框句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试隐藏默认的datagridview错误对话框.我在事件处理程序中输入了代码:

I am trying to hide default datagridview error dialog. I put in the code this event handler:

        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单元保留为空(从中删除所有内容)时,它向我显示错误对话框.

But still when i try this and leave datagridview cell empty ( delete everything from it), it show me dialog box with error.

错误截图:

推荐答案

尝试处理并取消该事件:

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

另外,在 InitializeComponent()

private void InitializeComponent()
{
   //...
   this.dataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.dataGridView2_DataError);
}

这篇关于dataGridView默认错误对话框句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆