E
emorgoch.public
Hello there,
I have a form that gets shown using the ShowDialog() method. This form
then has it's accept and cancel button properties set. If hte user hits
the cancel button / hits ESC, the form is closed and they're returned
to the parent form. If the use then clicks the accept button / hits
enter, a different part of the form become enabled for them to work
with. Here's where I'm running into a bit of a problem:
When I enable this new part of the form, I also change the forms Accept
& Cancel button properties to a different set of buttons to save /
cancel data changes. If the user hits the second cancel button, no
changes occur, the new part of the form becomes disabled again, and the
control focus is returned to first part of the form (which was also
disabled when the second part was enabled).
However, in my testing, if the user hits the ESC key, the form is
closed no matter what is in the button event handler. From my trial and
error testing, it seems that this is a global property of any dialog
that is displayed using ShowDialog, and has it's CancelButton property
set.
Now, I've coded up a work around for this by having the cancel button
set a form variable, and then writing a Closing event handler to check
to see if that variable is set. But that seems like a poor way of doing
it, and that there should be another option.
Any suggestions / comments? Thanks
I have a form that gets shown using the ShowDialog() method. This form
then has it's accept and cancel button properties set. If hte user hits
the cancel button / hits ESC, the form is closed and they're returned
to the parent form. If the use then clicks the accept button / hits
enter, a different part of the form become enabled for them to work
with. Here's where I'm running into a bit of a problem:
When I enable this new part of the form, I also change the forms Accept
& Cancel button properties to a different set of buttons to save /
cancel data changes. If the user hits the second cancel button, no
changes occur, the new part of the form becomes disabled again, and the
control focus is returned to first part of the form (which was also
disabled when the second part was enabled).
However, in my testing, if the user hits the ESC key, the form is
closed no matter what is in the button event handler. From my trial and
error testing, it seems that this is a global property of any dialog
that is displayed using ShowDialog, and has it's CancelButton property
set.
Now, I've coded up a work around for this by having the cancel button
set a form variable, and then writing a Closing event handler to check
to see if that variable is set. But that seems like a poor way of doing
it, and that there should be another option.
Any suggestions / comments? Thanks