且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

不会触发所有形式的textBox验证

更新时间:2023-11-21 19:16:16

仅当接收焦点的控件的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属性.