I have searched for the question that when is the validating event fired but the answer I found so far is that when the validation starts. What I want to know is the actual firing time of the validating event. For example, the click event is fired when a control is clicked by either mouse or keyboard and similarly leave is fired when a control is no more the current focused control. So what is the explanation of validating event being fired?
Asked
Active
Viewed 947 times
0
-
Did you try [MSDN](https://msdn.microsoft.com/en-us/library/system.windows.forms.control.validating(v=vs.110).aspx)? Its pretty clear. Btw it has nothing to do with visual studio. – CodingYoshi Aug 28 '17 at 05:24
1 Answers
0
The Validating event is fired only when the control that receives the focus has the CausesValidation property set to true. For example, if you have written code in TextBox'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 would not be able to fire.

Vikas Gupta
- 1,183
- 1
- 10
- 25
-
-
Because the control like " textbox " loses the focus and set the property CausesValidation to false. – Vikas Gupta Aug 28 '17 at 05:59
-
I am sorry, If that is not helping you..So read this..https://stackoverflow.com/questions/4464256/how-to-set-focus-to-a-control-after-validation-in-net This might help you with focus. – Vikas Gupta Aug 28 '17 at 05:59
-
So simply we can say that validating depends on causesValidation bool value. And text box set this bool value by default. Thanks bro. Now I get it. – Zeebo Khan Aug 28 '17 at 06:32