Datagridview验证 [英] Datagridview Validation

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

问题描述

我有一个未绑定的Datagridview,我需要在用户尝试更改单元格时(例如,当他们点击新单元格或制表符时,但在他们进入新单元格之前)验证单元格的内容。" 我无法在Cellvalidating中执行此操作,因为(我认为)只要
单元格内容发生更改就会触发此操作,我无法在那里执行此操作,因为单元格内容必须完整才能验证(例如某些单元格包含人名)。


谢谢

解决方案

这里有一个绑定的DataGridView你可以在数据的事件中做验证而不是比对照。例如,如果您使用过DataTable,则可以订阅DataColumChanging(请参阅
简单示例

I have an unbound Datagridview, I need to validate contents of cells when the user attempts to change cells (i.e. when they click a new cell or tab but before they enter the new cell).  I cannot do this in Cellvalidating as (I think) this is fired whenever the cell contents change, I can't do it there because the cell contents must be complete to validate (for example some cells contain person's names).

Thanks

解决方案

Here is where having a bound DataGridView you could do validation in events for the data rather than the control. For instance if you had used a DataTable you could subscribe to DataColumChanging (see simple example)


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

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