943,940 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 19572
  • C# RSS
Feb 15th, 2006
0

Closed event of a form

Expand Post »
I have a problem, with a closed form event.
I'd like to make a check with a click on close botton in the title bar that check if the user are sure or not to close the application.
I have made a method that ask if the user are sure when click on the X in the title bar but when the user select the no option what must I do to evitate that the application was closed??

Thanks a lot for the help.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
lorf14plus is offline Offline
20 posts
since May 2005
Feb 15th, 2006
0

Re: Closed event of a form

could you ask that again in english?
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Feb 16th, 2006
0

Re: Closed event of a form

Quote originally posted by campkev ...
could you ask that again in english?
Sorry for my english.
I have made a windows form application.
My application is a Mdicontainer with many child form.
I want to check che closed event of this form, and when happend i want to intercept it and ask a confermation of closing application.
This part I don't have problem to implement.
My problem is the messagebox that ask if the user want really to close (Yes/No).
I have made a method that check if the Dialog result is Yes or no, but when the result it's no, want i can do to stopping the closing operation of the application??

Thanks a lot.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
lorf14plus is offline Offline
20 posts
since May 2005
Feb 16th, 2006
0

Re: Closed event of a form

C# Syntax (Toggle Plain Text)
  1. private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  2. {
  3. if(MessageBox.Show("Are you sure you want to close?", "Closing Program", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  4. e.Cancel = true;
  5.  
  6. }
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Feb 17th, 2006
0

Re: Closed event of a form

Thanks a lot for your help.

I have prove it and this work perfectly.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
lorf14plus is offline Offline
20 posts
since May 2005
Feb 17th, 2006
0

Re: Closed event of a form

de nada
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: opening programs
Next Thread in C# Forum Timeline: C# 2005 - ComboBoxes with Parent / Child relation in DataGridView





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC