D
David Veeneman
I am writing a control that relies on its host to validate the contents of
one of its fields. The control fires a custom 'FooNeedsValidating' event and
passes the field's data with the event. The host handles the event,
validates the data and returns the validation results to the control by a
callback to a control method, SetFooError(). All of that works great.
If the host returns false on the validation, I display an error glyph next
to the control field, using an error provider control. That works great,
too. But here is what I am having trouble with: I want to set the
CancelEventArgs for the field to true. I want to lock the user into the
field until the error is corrected, just as if the error had been detected
in a Validating event and I had set e.Cancel to true.
My problem is that in this case, the error is being reported in a callback,
rather than detected in an event handler. So, I've got no 'e' to hook into.
Is there any way to set the 'Cancel' property on the field outside of an
event handler? Thanks in advance.
one of its fields. The control fires a custom 'FooNeedsValidating' event and
passes the field's data with the event. The host handles the event,
validates the data and returns the validation results to the control by a
callback to a control method, SetFooError(). All of that works great.
If the host returns false on the validation, I display an error glyph next
to the control field, using an error provider control. That works great,
too. But here is what I am having trouble with: I want to set the
CancelEventArgs for the field to true. I want to lock the user into the
field until the error is corrected, just as if the error had been detected
in a Validating event and I had set e.Cancel to true.
My problem is that in this case, the error is being reported in a callback,
rather than detected in an event handler. So, I've got no 'e' to hook into.
Is there any way to set the 'Cancel' property on the field outside of an
event handler? Thanks in advance.