using the validated event on textbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony

    using the validated event on textbox

    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


  • =?Utf-8?B?TW9ydGVuIFdlbm5ldmlrIFtDIyBNVlBd?=

    #2
    RE: using the validated event on textbox

    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.

    --
    Happy Coding!
    Morten Wennevik [C# MVP]


    "Tony" wrote:
    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
    >
    >
    >

    Comment

    • Ignacio Machin ( .NET/ C# MVP )

      #3
      Re: using the validated event on textbox

      On Jun 24, 4:42 am, "Tony" <johansson.ande rs...@telia.com wrote:
      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

      Comment

      Working...