M
Martijn Boland
Hi all
I put multiple textboxes on a form and assigned a Validating event handler
to them (the same handler for all textboxes). In the event handler I check
if the Text property is empty. If so, I set e.Cancel to true
(CancelEventArgs), to cancel all further actions.
The problem is however that e.Cancel doesn't seem to work. For instance when
tapping on another textbox the Validating event is fired and e.Cancel is set
to true (as expected) but everything continues just af if nothing happened.
The tapped textbox gets focus and should not be the case! Then I tried to
force the focus back to the original textbox (after setting e.Cancel = true)
and guess what: BOOM! Yep the validating event of the tapped textbox was
also fired after setting focus back to the original textbox, resulting in an
infinite loop.
Now I wonder, am I doing something wrong, or is this a nasty bug in the
framework?
Thnx, Martijn
I put multiple textboxes on a form and assigned a Validating event handler
to them (the same handler for all textboxes). In the event handler I check
if the Text property is empty. If so, I set e.Cancel to true
(CancelEventArgs), to cancel all further actions.
The problem is however that e.Cancel doesn't seem to work. For instance when
tapping on another textbox the Validating event is fired and e.Cancel is set
to true (as expected) but everything continues just af if nothing happened.
The tapped textbox gets focus and should not be the case! Then I tried to
force the focus back to the original textbox (after setting e.Cancel = true)
and guess what: BOOM! Yep the validating event of the tapped textbox was
also fired after setting focus back to the original textbox, resulting in an
infinite loop.
Now I wonder, am I doing something wrong, or is this a nasty bug in the
framework?
Thnx, Martijn