I am using the FormClosing event on a C# Windows Form to ask the user to confirm before exiting. I only wish to show this message if the user specifically closes the form using the red cross in the corner of the form window. When I close or hide a form manually I do not wish to show the confirm message (e.g. manually calling form.Close()).
Is it possible to check to see if the user has pressed the red cross?
Thanks.
Check the FormClosingEventArgs.CloseReason property.