首页 > 技术文章 > DataGridView之DataError

YYkun 2017-07-03 14:16 原文

解决思路一:

 private void dgvChargeList_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            bool handle;
            if (dgvChargeList.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.Equals(DBNull.Value)) handle = true;
            else
            {
                handle = false;
                e.Cancel = handle;
            }
        }

解决思路二:

设置属性ShowCellErrors=false;

推荐阅读