Validating event

B

babylon

I have a form which contains a TextBox, and a 'submit' button which print
TextBox.Text to console
I added validating eventhandler to check if the Textbox is empty and set the
errorprovider if it is empty
and set CancelEventArgs.Cancel = true to make sure the user input something

however..it seems that the validating event only raised when the textbox is
in focus then lost focus
so if I show the form and click the 'submit' button immediately, the
validatin event will not be raised which means that I cannot make sure the
user entered something to the TextBox...

are there any methods to rise the validating event to the textbox or there
are better ways to handle this?
thx!
 
V

Velox

Why don't you just add the validating code to the submit button's
Click event? Another option would be to focus the TextBox when the
form is shown.

-Velox
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top