-
February 25th, 2012, 11:11 AM
#1
Detecting X button click of a window in winforms.
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.
-
February 25th, 2012, 11:26 AM
#2
Re: Detecting X button click of a window in winforms.
I think you need to do 2 things. 1 check the closereason and 2 set a flag anywhere you close the form through code. The closereason will = 3 if the x was clicked or you exited through code so if you set a flag just before you call your close method then in the closing event you check both your flag and the close reason you should be able to tell.
Flag is false and closereason is 3 x was clicked.
Always use [code][/code] tags when posting code.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|