WinForms 中的用户输入验证

发布于 2024-09-30 13:48:10 字数 164 浏览 7 评论 0原文

我在 WinForms 应用程序中创建了一些表单,并希望实现用户输入的验证。有几个组合框和文本框。我必须检查某些字段不为空,并且某些字段需要十进制数字格式。我知道有企业库验证块和集成的ErrorProvider。您对集成速度有何建议?

提前致谢。

I'm created a few forms in WinForms application and want to implement validation of user input. There are several ComboBox'es and TextBox'es. I have to check that some fields are not empty and some field require decimal number format. I know there are Enterprise Library Validation Blocks and integrated ErrorProvider. What way can you advice in terms of integration’s speed.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

初懵 2024-10-07 13:48:11

您可以在没有企业库的情况下完成此任务,除非您的应用程序确实是企业应用程序。

如果您引用 System.Windows.Forms.ErrorProvider 那么这将是最快的方法。是一个非常简单的组件,但我不进行验证,只是视觉辅助。因此,您必须“手动”进行验证。

You can do this task without enterprise library, unless your application is really an Enterprise application.

If you are refering to System.Windows.Forms.ErrorProvider then this would be the fastest way. Is a very simple component but I does not make validation, just visual aid. So you will have to do the validation "manually".

知你几分 2024-10-07 13:48:11

我有一个自定义类,其中定义了方法。我还利用委托来触发任何事件的方法。

已编辑**

本文可能有所帮助:C# 验证 TextBox 控件

I have a custom class where in methods are defined. I also make use of delegates to fire a method on any event.

Edited **

This article might help: C# Validating TextBox Control

花开柳相依 2024-10-07 13:48:11

我认为最好的方法是使用 正则表达式

您可以在每个元素失去焦点时调用验证,就像某些 Web 表单一样。

I think the best way is to use regular expressions

You can call the validation when each element loses focus, just like some web forms.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文