Use the ErrorProvider to display an error icon next to the invalid control, similar to the method above.
ERRORPROVIDER AND FOCUS FULL
This is more “web-like” where the actual full validation is executed on save but you show the invalid state.
But you can set the control to Invalid and set the InvalidMessage.
4) Depending on the valid state, let the form close (DialogResult OK) or keep the form open (DialogResult None). But you can set the control to Invalid and set the InvalidMessage. 3) If the control's content is not valid, pass it to the ErrorProvider's SetError method along with your validation message. I believe that it should fire everytime the textbox loses focus.ĭo not cancel the Validating event. Also, I concentrated on mouse click when I sent you the test project. But now, when I tried using Tab to go from one control to another, the Validating event doesn’t always fire. But still, I was able to make an entry into the next textbox even if the previous textbox hasn’t passed the validation yet. I agree with you about the request/response in a web app but in the sample I sent yesterday, I am cancelling the Validating event by setting e.Cancel to true. Cancel the Validating event: Wisej will force (it may fail if you keep clicking due to timing issues :)) the invalid control to gain the focus back, it will automatically set the Invalid property to true and you may optionally set the InvalidMessage tooltip.