Jeff Tullin

Check out the .Closing Event of the form. It has a parameter which is read/write.

The help says 'The Closing event occurs as the form is being closed.... If you cancel this event, the form remains opened. To cancel the closure of a form, set the Cancel property of the CancelEventArgs passed to your event handler to true.'

If this means the form does not close when you want it to, try having a member property like m_bYesIReallyMeanIt which you can set and check...

dilina fonseka

Mohammad Rastkar

Shiraz, Iran

Joined 11 years ago

OK, you're idea is good that we should express clearly, but some times you should search by yourself, for what you don't know and get some knowledge some where else.

Anyway, about 'm_bYesIReallyMeanIt' : I think it's about this : when you cancel closing a form by setting 'Cancel' member of 'FormClosingEventArgs' parameter of the form's 'FormClosing' event, you may want [for example] when user press 'Alt + F4' don't close that, but if he pressed the close button of your form, close it. Then you should distinguish these two situations, then you can declare 'm_bYesIReallyMeanIt' bool variable as default value of 'false' and when the user pressed 'Alt+F4' set that to 'true', then in 'FormClosing' event, you can assign 'm_bYesIReallyMeanIt' to 'e.Cancel' . Then we assumed 'm_bYesIReallyMeanIt' means : I really want to notclose the form. I don't know what I said though!!