不会触发所有形式的textBox验证 [英] Validation of textBox in all forms is not firing
问题描述
大家好,
我正在构建一个在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 textBox
es but suddenly I found that all validation of all textBox
es in all form
s in my system are not firing ,
I tried to trace the validation
codes but the trace never reach the validating
event
s.
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
事件.
TheValidating
event is raised only when the control that receives the focus has theCausesValidation
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 theValidating
event is raised, but if you click the Cancel button (CausesValidation = false) then theValidating
event is not raised.
您可以causesValidation
和validationgroup
属性.
这篇关于不会触发所有形式的textBox验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!