0

Windows 窗体应用程序 C#

TextBox在 windows 上有四个Form。我已经编写了代码来处理Text_Validating每个文本框的事件。现在,当用户单击提交时,Button我希望那些 text_validating 事件自动触发。

Button 的EnabledCausesValidation属性。

我们在 ASP.net 中有一个叫做 validationGroup 属性的东西,它是如何在 Windows 应用程序中实现的

请帮我解决这个问题

谢谢你

4

4 回答 4

0

Winforms此外,您可以使用以下验证器编写自己的验证器控件,例如 asp.net:- 。

RequiredFieldValidator  
RegularExpressionValidator  
CompareValidator    
RangeValidator  
CustomValidator

这是关于如何使用自定义验证库扩展 Winforms 的分步说明和演练 - http://msdn.microsoft.com/en-us/library/ms950965.aspx

于 2012-06-23T15:25:10.817 回答
0

一种选择是简单地调用传入必要参数的验证方法(空值可能会起作用 - 显示代码将有助于确定是否有必要)。

于 2012-06-22T21:19:38.383 回答
0

我相信 Text_Validating 事件仅在控件的焦点更改时触发。如果您对提交验证感兴趣,您可以执行用户 Bruce 在这篇文章中提出的建议。

于 2012-06-22T21:27:25.833 回答
0

单击按钮时,请使用:

if(ValidateChildren())
{
      //do stuff
}
于 2017-04-12T00:04:32.600 回答