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.