如何验证窗口应用程序中的字段 [英] How to validate field in window application

查看:58
本文介绍了如何验证窗口应用程序中的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用c#开发桌面应用程序.
我想先验证所有字段,然后再将其保存到数据库中?

i am developing a desktop application in c#.
i want to validate my all field before it will save to database ?

推荐答案

您可以对文本框使用Validating事件(或)在按钮click事件中,您可以检查使用Text属性使用其ID(即,对于桌面应用程序为Name)来为特定的文本框设置值.
You can use Validating event for textbox (or) In the button click event you can check the value particular text box with the Text property using its ID(i.e., Name in case of desktop applications).


嗯,这取决于您的要求.
如果您想以特定模式获取输入,或者只使用KeyPress Event过滤出字母或数字值,否则,我建议您使用正则表达式(Regex).
Well, it depends upon your requirement.
I will suggest you to use Regular Expressions (Regex) if you wanted to get input in specific pattern or for just use KeyPress Event to filter out Alphabetic or Numeric Values or else.


这篇关于如何验证窗口应用程序中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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