读书人

DataGridView.CellValidating 事件的有

发布时间: 2012-01-26 19:40:46 作者: rapoo

DataGridView.CellValidating 事件的问题
我调协了这个事件,我是用手去邦定数据

邦定数据的时候就报错了,好像就在执行这个事件

不知道怎么解决?


private void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
dataGridView1.Rows[e.RowIndex].ErrorText = " ";
int newInteger;

// Don 't try to validate the 'new row ' until finished
// editing since there
// is not any point in validating its initial value.
if (dataGridView1.Rows[e.RowIndex].IsNewRow) { return; }
if (!int.TryParse(e.FormattedValue.ToString(),
out newInteger) || newInteger < 0)
{
e.Cancel = true;
dataGridView1.Rows[e.RowIndex].ErrorText = "the value must be a non-negative integer ";
}
}


[解决办法]
使用CellValidated呢?
[解决办法]
细看:不可能啊!出什么错?

-----------------
我手动绑定不会出错!

读书人网 >C#

热点推荐