How to ask user to exit or no for a winform app

  • Thread starter Thread starter Sylvain Bissonnette
  • Start date Start date
S

Sylvain Bissonnette

Hi,

I'm wonderring how can I ask to the user after he had click the X of a
form
if he really want to exit this program?

Thanks for your help
Sylvain Bissonnette
 
Add an event handler for the Closing event of the main Form, prompt the
user, and then set the Cancel property of the CancelEventArgs object passed
to the event handler to "true" if the user requests to not close the app.
Or, if you're targeting .NET Framework 2.0 (VS 2005), then use can use the
FormClosing event and set the Cancel property of the FormClosingEventArgs
object to "true" if the user requests to not close the app. The FormClosing
event was introduced in the .NET Framework 2.0 version and is a more
flexible version of the Closing event as it also specifies the reason that
the Form is closing.
 
Hi Tim,

Thanks a lot for your reply and usefull information you gave me,
I just try what you wrote and it's work just fine!

Thanks again
Sylvain Bissonnette
 
Hi Tim,

Thanks a lot for your reply and usefull information you gave me,
I just try what you wrote and it's work just fine!

Thanks again
Sylvain Bissonnette
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top