[英]How to cause textbox validation on button click automatically in c#
Windows Form Application C# Windows 窗体应用程序 C#
I have four TextBox
on windows Form
.我在 windows
Form
上有四个TextBox
。 i have written code to handle Text_Validating
event for each textbox.我已经编写了代码来处理每个文本框的
Text_Validating
事件。 Now when user clicks on submit Button
i want those text_validating events to fire automatically.现在,当用户单击提交
Button
时,我希望那些 text_validating 事件自动触发。
Enabled CausesValidation
property of Button.已启用 Button 的
CausesValidation
属性。
We have something called validationGroup Property in ASP.net how it can be implemented in windows application我们在 ASP.net 中有一个叫做 validationGroup 属性的东西,它是如何在 Windows 应用程序中实现的
pls help me to solve this problem请帮我解决这个问题
thank you谢谢你
一种选择是简单地调用传入必要参数的验证方法(空值可能会起作用 - 显示代码将有助于确定是否有必要)。
Also, you can write own Validator controls like asp.net in Winforms
with following validators:- .此外,您可以使用以下验证器在
Winforms
中编写自己的验证器控件,如 asp.net:-。
RequiredFieldValidator
RegularExpressionValidator
CompareValidator
RangeValidator
CustomValidator
Here is a step by step explanation and walkthrough on how to extend Winforms with a custom validation library - http://msdn.microsoft.com/en-us/library/ms950965.aspx这是关于如何使用自定义验证库扩展 Winforms 的分步说明和演练 - http://msdn.microsoft.com/en-us/library/ms950965.aspx
On button click, go with:单击按钮时,请使用:
if(ValidateChildren())
{
//do stuff
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.