Pop up MessageBox and close whole program

  • Thread starter Thread starter ahjiang
  • Start date Start date
A

ahjiang

Hi all,

I have this messagebox that prompts when a fatal error occurs and i
would like the user to click okie and the whole pgm would exit

MessageBox.Show(errorMsg, "Error");

how am i able to do it?

appreciate any help
 
Hi ahjiang,

Hi all,

I have this messagebox that prompts when a fatal error occurs and i
would like the user to click okie and the whole pgm would exit

Hope this helps,

DialogResult ret = MessageBox.Show("Show", "Exit",MessageBoxButtons.YesNo);
Console.WriteLine(ret.ToString());
if (ret == DialogResult.Yes)
Application.Exit();
else if (ret == DialogResult.No)
MessageBox.Show("Pressed No");

DialogResult stores the button value what is been clicked. With that you can
get all return types.

Regards,
C.C.Chakkaradeep
 
if(DialogResult.Yes == MessageBox.Show("Really quit?", "Quit",
MessageBoxButtons.YesNo))
{
Application.Exit();
}

HTH

Simon
 
Back
Top