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!

Re: Validating event by velox1

velox1
Mon Oct 27 14:16:25 CST 2003

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

"babylon" <amuro@hotmail.com> wrote in message news:<Oq2G$AEnDHA.3504@TK2MSFTNGP11.phx.gbl>...
> 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!