0

Hi all, I m using C# from Quite some time. I m facing a problem regarding my project. The problem is
When the user clicks on the close button on any form it displays the messagebox saying Do u really want to quit or not?. This MessageBox contains two buttons Yes And No. Now the Problem is If a user clicks on the Yes button The form must get closed whick is quite simple. But.... when a user clicks on the No button then the form must not closed. I dont have any idea how to stop the closed form event.
thanks in advance for any suggestions

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by JerryShaw
0
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
	if ((Interaction.MsgBox("Are you sure want to quit?", MsgBoxStyle.YesNo, "Exit")) == MsgBoxResult.Yes)
	{
		ProjectData.EndApp();
	}
	else
	{
		e.Cancel = true;
	}
}
0

Is ProjectData.EndApp(); really needed ?
If e.cancel is left alone (not set to true), the program is going to close normally.
Doesn't EndApp() force an application termination disregarding any event assigned to Form_Closed ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.