P
polocar
Hi,
suppose that you have a C# form with two buttons, that are the
classical "btnOk" and "btnCancel" (besides them, of course in
the form there can be many other controls).
When the user clicks on btnOk, the program makes some confirm
operations and closes the form.
When the user clicks on btnCancel, the program makes some cancel
operations and closes the form.
My problem is that, when the user clicks on the "X" button of the
form caption bar, the form simply closes, while I would like that the
program made the same cancel operations as in the btnCancel click case.
I have discovered that the Form class has the "OnClosing" event
handler (that is executed when the form closes), but I can't insert
the cancel statements in its code (it is executed when the user clicks
on btnOk and btnCancel too, so the program would execute two times the
cancel operations or first the confirm operations and then the cancel
ones).
Is there a form event handler for the "X" form button click?
Or is there a form property that allows to associate the "X" form
button click to a button inside the form (btnCancel, in this case)?
Otherwise, can you propose me a simple way to handle this situation?
Thank you very much
suppose that you have a C# form with two buttons, that are the
classical "btnOk" and "btnCancel" (besides them, of course in
the form there can be many other controls).
When the user clicks on btnOk, the program makes some confirm
operations and closes the form.
When the user clicks on btnCancel, the program makes some cancel
operations and closes the form.
My problem is that, when the user clicks on the "X" button of the
form caption bar, the form simply closes, while I would like that the
program made the same cancel operations as in the btnCancel click case.
I have discovered that the Form class has the "OnClosing" event
handler (that is executed when the form closes), but I can't insert
the cancel statements in its code (it is executed when the user clicks
on btnOk and btnCancel too, so the program would execute two times the
cancel operations or first the confirm operations and then the cancel
ones).
Is there a form event handler for the "X" form button click?
Or is there a form property that allows to associate the "X" form
button click to a button inside the form (btnCancel, in this case)?
Otherwise, can you propose me a simple way to handle this situation?
Thank you very much