确认没有重复 [英] Verify there are no duplicates

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

问题描述

如果我有绑定到绑定源/适配器的datagridview,并且创建了新行,那么验证这是否是重复行的最佳方法是什么?例如,如果添加一行将是重复的行,然后单击该行,则会出现讨厌的运行时错误,指出该行是重复的.我假设此验证是在bindinsource或datagrid视图中进行的,但是我不确定它在哪里.我想在不显示讨厌的运行时错误的情况下通知用户.

感谢

If I have a datagridview that is bound to a bindingsource/Adaptor, and I create a new row, what is the best way to verify if this is a duplicate row or not?  For instance, If I add a row that would be a duplicate, and I click out of the row, I get the nasty runtime error that the row is a duplicate.  I assume that this validation is either happening in the bindinsource or the datagrid view but I'm not sure where it is.  I want to notifiy the user without showing the nasty run time error.

Thanks

推荐答案

您好,

我认为重复检查正在数据源中进行.可能会有一列标记为唯一的列,当您输入已经存在的某个值时,它将引发异常.

IMO,您可以捕获该异常并向用户显示用户友好的消息.

问候,
Hi,

I think the duplication check is happening in the data source. There might be a column marked as unique, and when you enter some value which is already present, then it throws the exception.

IMO, you can catch that exception and display an user friendly message to your user.

Regards,


这篇关于确认没有重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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