读书人

CellValidating验证异常怎么清空单元格

发布时间: 2012-02-02 23:57:14 作者: rapoo

CellValidating验证错误如何清空单元格?

C# code
        protected override void OnCellValidating(DataGridViewCellValidatingEventArgs e)        {                    string c = dgsele.CurrentRow.Cells["编号"].Value.ToString();                    if (c != "")                    {                        MessageBox.Show(" 找不到对应编号!" , "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);                        e.Cancel = true;                        //目前我只能这样清空单元格                        SendKeys.Send("{BACKSPACE}");                    }        }//我很奇怪,为什么用下面的代码都无法清空this.CurrentCell.Value=""; this[e.ColumnIndex, e.RowIndex].Value = ""; 


[解决办法]
难道是因为清完后没刷新

读书人网 >C#

热点推荐