954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Closed event of a form

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.

lorf14plus
Newbie Poster
20 posts since May 2005
Reputation Points: 10
Solved Threads: 1
 

could you ask that again in english?

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 
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.

lorf14plus
Newbie Poster
20 posts since May 2005
Reputation Points: 10
Solved Threads: 1
 
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
				if(MessageBox.Show("Are you sure you want to close?", "Closing Program", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
					e.Cancel = true;
			
		}
campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

Thanks a lot for your help.

I have prove it and this work perfectly.

lorf14plus
Newbie Poster
20 posts since May 2005
Reputation Points: 10
Solved Threads: 1
 

de nada

campkev
Posting Pro in Training
484 posts since Jul 2005
Reputation Points: 14
Solved Threads: 19
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You