Hi all,
I've a code in vb.net 2003 which prompts user while he/she tries to close the form by clicking the form's close button('X'). If answer is yes the form closes but if the answer is no it stays. Now I want to write the similar code in a C# form also. I've already coded it. It's also working but the problem is when I'm trying to not to close the form by clicking on the 'NO' button in the messagebox the form still closes itself. Here is the code fragment what I wrote :-
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
int confirm;
confirm=System.Convert.ToInt32(MessageBox.Show("Sure to exit ?","Confirm Exit",MessageBoxButtons.YesNo,MessageBoxIcon.Question));
if(confirm==6)
{
Application.Exit();
}
[B]else
if(confirm==7)
{
//e.Cancel;
return;
}[/B]
}
The bolded part is where I'm getting the problem. Plz help me to figure this out. I'm a beginner in C#. So, if anybody can help me plz do so. Thanks in advance...