管理DataGridView新记录 [英] Managing DataGridView New Record

查看:82
本文介绍了管理DataGridView新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

DGV.DataSource = BindingSource

DGV.DataSource = BindingSource

我将我的数据表作为上面的代码填充到DGV,并带有"允许添加"。属性。但我无法管理"新纪录"。当我必须将此记录添加到"BindingSource"时,我想强制用户在必填单元格中输入数据。当
用户按下键盘上的ESC键时,我的DGV忽略强制单元格并删除"新记录"。

I populated my data table as above code to DGV with "Allowed Add" property. but I can not manage "New Record". I want to force user to enter data in mandatory cell when this record must be added to me "BindingSource" and when user press ESC key on keyboard, my DGV ignore mandatory cell and delete "New Record".

为强制单元格我将我的代码放入"RowValidating"中。事件,但ESC不起作用。

for the mandatory cell I put my code in "RowValidating" event but ESC dose not work.

我该怎么办?

提前谢谢大家

推荐答案

尝试使用
AllowDBNull
= False
Try setting required fields with AllowDBNull = False


这篇关于管理DataGridView新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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