I want to preform a check before my form is closed.
how can I do this when a user hits Alt + F4 or clicks the close button on my form?
Printable View
I want to preform a check before my form is closed.
how can I do this when a user hits Alt + F4 or clicks the close button on my form?
When a form is about to close, it raises its FormClosing event. You can handle that event and perform whatever actions you need to perform. To prevent the form closing, just set e.Cancel to True. Just be careful that you don't prevent Windows exiting as a result. The e.CloseReason property can tell you why the form is closing.
yes, i have tested your way, but i saw some problem, hic!!!
Are you sure? I was thinking it was line 8...
-tg
I dont get it, I'm only seeing 6 lines of code :confused:
I had no code as I wasn't sure how to start, your reply was helpful. Others, well perhaps a more more social interaction with others is in need :rolleyes:
Uh-huh... ok...
"yes, i have tested your way, but i saw some problem, hic!!!" <--- this implied you had tried some code and it didn't work...
-tg
You said that you had tested and saw a problem but if you had no code then how could you have tested? It may not seem like a big deal to those who post a question now and again but those of us who answer lots of questions every day have to wade through a morass of poorly worded posts. Posts that ask for help with code that they do not provide are common and frustrating.
:) all good, thanks for your original help
Sorry ubkra, technome and my own reply wasn't aimed towards you but to skyman2610 who said that he had some problems with it but never expanded on what the problem was and didn't post any code. I think jmcilhinney just mixed up your question with skyman2610's reply, that's one of the thing that can happen when somebody hijacks someone else's thread.