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.

Recommended Answers

All 3 Replies

Iam affraid, you will ahve to use FormClosing event to get the event of that X button for closing form!

The FormClosingEventArg has a CloseReason property, which has one of the CloseReason Enumeration values. Check MSDN for documentation.

Use FormClosing event.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.