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

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;
	}
}

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 ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.