Right, that might work on a small scale. The issue being that this is for a
generic framework, and it is not known ahead of time what controls will be
on the form. So this needs to happen without having to write special code
for each form...
>I have a form Control type variable (acceptok) that I set to = the control
> causing the error in the validation or lostfocus event then in the OK
[quoted text clipped - 36 lines]
>> >
>> > It seems like a pretty common scenario? How do people deal with this?
Francisco Garcia - 29 Sep 2005 14:21 GMT
Hi,
Just set the Cancel property of the Validating event arguments (of type
CancelEventArgs) to true.
It will prevent your control from losing focus, and any further processing
(like the button getting focus and being clicked) will be canceled.
Hope it helps
> Right, that might work on a small scale. The issue being that this is for
> a generic framework, and it is not known ahead of time what controls will
[quoted text clipped - 41 lines]
>>> >
>>> > It seems like a pretty common scenario? How do people deal with this?
Marina - 29 Sep 2005 18:01 GMT
Validating does not get called in this case at all. That is my whole
problem. Sorry, but did you read my post?
Clicking on some controls does not raise the validation events. Such as
those that do not support the CausesValidation property.
> Hi,
>
[quoted text clipped - 55 lines]
>>>> >
>>>> > It seems like a pretty common scenario? How do people deal with this?
david - 30 Sep 2005 04:30 GMT
> Right, that might work on a small scale. The issue being that this is for a
> generic framework, and it is not known ahead of time what controls will be
> on the form. So this needs to happen without having to write special code
> for each form...
My general solution to this is to have each data item (not the control,
but the object that drives it) register to a standard validation class.
A click on the ok button only submits if all registered items have
indicated that they are now valid.
Often I prefer not to enable the OK button until the form has validated,
but that just doesn't work correctly with data binding or validation
events.
>>I have a form Control type variable (acceptok) that I set to = the control
>> causing the error in the validation or lostfocus event then in the OK
[quoted text clipped - 36 lines]
>>> >
>>> > It seems like a pretty common scenario? How do people deal with this?