datagridview中的单元验证 [英] Cellvalidating in datagridview

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

问题描述

大家好,

是否可以使用正则表达式验证datagridview的单元格?我也正在使用组合框加载datagridview,即根据选择在组合框中提供表名,相应的表数据将被加载到网格视图上.并且所有表都没有相同的数字列.如何验证这一点.请提供解决方案

谢谢您

Hello everyone,

Is it to possible to validate cells of datagridview using regular expression? Also i am loading datagridview using combo box i.e table names are provided in the combo box depending on the selection corresponding tables data will be loaded on to the grid view. And all the tables do not have same number columns. How to validate this. Please provide the solution

Thank you

推荐答案

http://msdn .microsoft.com/en-us/library/7ehy30d4.aspx [ ^ ]

http://stackoverflow.com/questions/4742960/datagridview-validation-changing-cell-value [^ ]
http://msdn.microsoft.com/en-us/library/7ehy30d4.aspx[^]

http://stackoverflow.com/questions/4742960/datagridview-validation-changing-cell-value[^]




我想您是不会在寻找其他架构上的答案.
每个表都会动态创建自己的模板集,因此没有一种简单的方法可以使用模板来定义您的验证.

但是,每一行都有一个rowdatabind方法,该方法将在绑定事物时触发.
您可以通过编程方式截取此验证控件并将其添加到单元格(当然将其正确链接),您需要从某处获取正则表达式并将其数据绑定到其中.

基本上,用代码创建您的验证,您的rowdatabind方法会变得很繁琐.

另一种可能是在网格绑定后循环通过网格,并在其中添加验证控件.

希望这对您有帮助...
Hi,

I assume you not looking for another architectural answer so.
Each table creates its own set of templates on the fly so there''s no easy way to use the template to define your validations.

However each row has a rowdatabind method which is fired when things get bound.
You could intercept this add a validation control progammatically to the cell (linking it properly of course), you would need to source the regular expression from somewhere and databind that in.

Basically your rowdatabind method would become quite heavy with code to create your validations.

Another possiblity may be to loop through your grid after its bound and add the validation control in.

Hope this helps...


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

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