Simple ErrorProvider question

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

    #1

    Simple ErrorProvider question

    I've never used this little control, but found a reason too. So, I want to
    prevent the user from moving on, until the error condition has been
    satisified. I have a textbox and raise the Validated event that does the
    errorchecking. If an error exists, i don't want the user to move on, what's
    the best way to handle this?

    Doug


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Simple ErrorProvider question

    Doug,

    If there is an error, then you should set the Cancel property on the
    CancelEventArgs instance passed to your Validating event handler to true.
    This will cause the focus NOT to shift.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Doug Handler" <dkhandler@yaho o.com> wrote in message
    news:OZCLtySIGH A.3176@TK2MSFTN GP12.phx.gbl...[color=blue]
    > I've never used this little control, but found a reason too. So, I want
    > to prevent the user from moving on, until the error condition has been
    > satisified. I have a textbox and raise the Validated event that does the
    > errorchecking. If an error exists, i don't want the user to move on,
    > what's the best way to handle this?
    >
    > Doug
    >[/color]


    Comment

    • Bruce Wood

      #3
      Re: Simple ErrorProvider question

      You want to check for errors in the Validating event, not the Validated
      event, and then, as Nicholas pointed out, set the Cancel property of
      the ValidatingEvent Args to false in order to stop the focus change.

      The Validated event is useful if you need code to take action _only if_
      the validation succeeded and the user is about to leave the field as a
      result.

      Comment

      Working...