Click here to Skip to main content
15,890,399 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can I detect the click event of the close (X) button at the top right corner of the control box of a form/window? Please note, I don't want to know about CloseReason, FormClosing, FormClosed or stuffs like these, unless they are inevitable. I exactly want to detect if the user clicked the X button of the form. Thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 25-Feb-12 22:34pm    
When you ask that you need something unusual, you should explain why. In particular, "I don't want to know..." sounds totally unreasonable (and even rude), and handling FormClosing could be the solution, and the real reason is just that you did not get the purpose of this event.

Anyway, a person with "I don't want to know" attitude does not deserve and answer. I can face with "I don't want to tell you" response, which would be fair enough...
--SA
priyamtheone 5-Mar-12 5:20am    
@SAKryukov- First of all, I posted a question to seek a solution of a problem that is 'mine'. So I'll decide if things are unreasonable. Secondly, I think you didn't notice 'Please note' before 'I don't want to know...'. Anything said with a 'Please' cannot be rude. Rather, I would say it was being honest 'coz I really didn't want to know about those issues as I am already done with them. If you found it unusual and wanted a broader explanation, you could simply ask for it. There was no need to pull out those 'rude' and 'attitude' things, 'coz 'that' is unreasonable. Still if you can't face it, you shouldn't have dealt with it in the first place. Nobody forced you to read and post here.
The world could be made a better place by correcting our own faults rather than finding them in others.

1 solution

check this out:

how-to-know-user-has-clicked-x-or-the-close-button[^]

hope it helps :)
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Feb-12 22:36pm    
This discussion really contains the answer, and it is using the "CloseReason". The first solution is not reliable. I wish you mentioned it in your answer, otherwise it could confuse. Therefor, I voted 4, not 5. :-)
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900