How to detect whether a FormClosing event is from a user [X] button clicking?

347 Views Asked by At

In the FormClosing event handler of a Windows Form, I want to detect if the event is from a programmatically Form.Close() method call or through a user action in the user interface (for example, by clicking the Close button [X] on the form window).

I must show a dialog to confirm with the user whether he/she really wants to exit the application only if the FormClosing event is through a user clicking [X] button.

Is it possible? If yes, how to do?

Thanks you all in advance.

0

There are 0 best solutions below