validation in windows forms (C#)

  • Thread starter Thread starter mishra712
  • Start date Start date
M

mishra712

Hi All,


I have a few text boxes on my WinForm which need to be validated before

they lose focus. For this I have used 'validating' event, which shows a

message box when the validation fails. What I want is that this
validation shouldn't take place when i click on the exit button. I have

set the 'Causes Validation' property of the Exitbutton as false, still
when I click on it the validating event gets fired.


Does anybody has solution to this?
Thanks in advance.


Abhishek
 
Hi Abhiskek,

Your on the right track but.

In your exit buttons handler you need to set the CausesValidation
property to false for the items you wish to ignore.

eg.

if you have two textboxes that normally validate, in your exit button
handler:

textBox1.CausesValidation = false;
textBox2.CausesValidation = false;

Hope this helps

Simon
 
Hi Simon,
Thanks for the valuable suggestion, it did made my code work the way I
wanted it to.

Regards,
Abhishek
 
Back
Top