using the validated event on textbox

T

Tony

Hello!

There is an event Validating that can be used on TextBox that are very
useful but
there are also an event named Validated that I can't find much use of.

Have you see any useful times where this event Validated can be used ?

//Tony
 
M

Morten Wennevik [C# MVP]

Hi Tony,

Validated can be used to perform validating code that shouldn't be run if
Cancel is set in the Validating event. Granted, you could just put the code
in an if block in the Validating event as well, but separating the code to
Validated allows cleaner code. Particularly if someone overrides Validating
and forgets to add the 'Validated' code.
 
I

Ignacio Machin ( .NET/ C# MVP )

Hello!

There is an event Validating that can be used on TextBox that are very
useful but
there are also an event named Validated that I can't find much use of.

Have you see any useful times where this event Validated can be used ?

//Tony

Hi,

That you haven't used it yet (you will some day) it does not say is
not useful.
It's fired if and when the validating passed.
At that point you know that the value of the control is valid and you
can use it accordingky.

A simple example is that Validating check if the value is numeric , if
you get to validated you know for sure it's numeric and you can use it
for any calculation without the danger that it cannot be converted tu
number
 

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