G
Guest
Usage:
I have a dialog box, with default button with DialogResult.OK, cancel button
with DialogResult.Cancel, and a few dynamically added usercontrols.
In these usercontrol, there is another usercontrol with a textbox, that
required specific text to be entered.
On TextBox.Validating(.....), I set e.Cancel = True, to stop leaving
textbox, for some reasons.
Problem:
Clicking Cancel button closes form, thats ok. OK button is not clickable if
textbox is validated with e.Cancel=True. But if I press ENTER, OK button is
executed, and a form is closed. Validating event is fired, but it does
nothing to prevent form closing.
Question:
How to implement correct validation, and prevent form closing while
remaining DefaultButton functionality (all validation must be done in some
child control)?
I have a dialog box, with default button with DialogResult.OK, cancel button
with DialogResult.Cancel, and a few dynamically added usercontrols.
In these usercontrol, there is another usercontrol with a textbox, that
required specific text to be entered.
On TextBox.Validating(.....), I set e.Cancel = True, to stop leaving
textbox, for some reasons.
Problem:
Clicking Cancel button closes form, thats ok. OK button is not clickable if
textbox is validated with e.Cancel=True. But if I press ENTER, OK button is
executed, and a form is closed. Validating event is fired, but it does
nothing to prevent form closing.
Question:
How to implement correct validation, and prevent form closing while
remaining DefaultButton functionality (all validation must be done in some
child control)?