不会触发所有形式的textBox验证 [英] Validation of textBox in all forms is not firing

查看:53
本文介绍了不会触发所有形式的textBox验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在构建一个在textBox es中插入数据后正在使用大量验证的系统,但是突然我发现系统中所有form中所有textBox es的所有验证都没有触发,
我尝试跟踪validation代码,但跟踪从未达到validating event s.

当我尝试打开一个新项目并测试textBox的验证时,它运行得很好.

我试图重新创建新控件,以重新启动Visual Studio并重新启动Windows,但同样的问题也面临着我.我发现的唯一解决方案是将验证代码复制到event TextBox_Leave.
还有其他选择吗,有人能告诉我为什么这个问题面对我吗?
我应该怎么做才能使验证事件触发?
我应该用Leave事件处理程序替换它吗?
这是Visual Studio的问题吗?

预先感谢,
:)

Hi all,

I was building a system where I was using a lot of validation after inserting data in textBoxes but suddenly I found that all validation of all textBoxes in all forms in my system are not firing ,
I tried to trace the validation codes but the trace never reach the validating events.

When I tried to open a new project and test the validation of a textBox ,it was running great.

I tried to recreate new controls , to restart visual studio and restart my windows but the same problem faced me. Theonly solution I found is to copy the validation code to the event TextBox_Leave.
Is there any other choices , can anyone tell me why this problem faced me ?
What should I do to let the validating event fire ?
Should I replace it with the Leave event handler ?
Is this problem from the visual studio ?

Thanks in advance,
:)

推荐答案

仅当接收焦点的控件的CausesValidation属性设置为true时,才会引发Validating事件.例如,如果您已在TextBox1的Validating事件中编写了代码,然后单击OK按钮(CausesValidation = true),则会引发Validating事件,但是,如果您单击Cancel按钮(CausesValidation = false),则会出现不会引发Validating事件.
The Validating event is raised only when the control that receives the focus has the CausesValidation property set to true. For example, if you have written code in TextBox1''s Validating event, and you click the OK button (CausesValidation = true) then the Validating event is raised, but if you click the Cancel button (CausesValidation = false) then the Validating event is not raised.


您可以causesValidationvalidationgroup属性.


这篇关于不会触发所有形式的textBox验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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