验证新添加到datagridview的行 [英] Validating a newly added row to datagridview

查看:107
本文介绍了验证新添加到datagridview的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将数据集绑定到DGV.单击添加按钮在DGV上添加一行并输入数据,必须检查新添加的行是否已经可用(如检查重复),如果可用,我也不应该在编辑时以相同的方式添加.如果有与此相关的任何事件,如何实现?请帮我解决这个DGV用法的新问题.

在此先感谢

Hi I''m binding a dataset to DGV. adding a row ot DGV on click of add button and entering the data, have to check whether newly added row is already available like checking duplication and if its available I should not add same way while editing also. How can this be achieved is there any event related to it, pls help me out I''m new to this DGV usage.

Thanks in advance

推荐答案

我还没有真正尝试过,但似乎显示了一些希望http://msdn.microsoft.com/en-us/library/det4aw50.aspx [
I haven''t really tried it, but it seems to show some promise http://msdn.microsoft.com/en-us/library/det4aw50.aspx[^] . For the filter expression string, you can construct it using the row values you add in the datagrid (assuming you are also propogating these changes back to the dataset). The filter thing may be a bit tricky since you don''t mention a clear primary key to check against, and so you may have to hack around a bit for that. If the returned array contains more than one value you would know that there are duplications and so you can reject the changes, otherwise accept them.

HTH
Cheers...


这篇关于验证新添加到datagridview的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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