views:

27

answers:

1

On Windows mobile 6.1 prof.

I have a messagebox with a yes/no button on it. When I click 'No' option in the messagebox, my whole application shutsdown, how can I simply close the messagebox?

                string message = "Application will perform a data download agree?";
                string caption = "";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult result = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                if (result == DialogResult.Yes)
                {

                    navigateForward(WEB_PAGE_NAVIGATE);

                }

                else
                {

                   this.Close();

                }
+2  A: 

You do not need to close the message box. It's a DialogWindow and will close itself when you click any of the options:

DialogResult result = MessageBox.Show();
if (result == DialogResult.Yes)
{
    navigateForward(WEB_PAGE_NAVIGATE);
}
else
{
    // No need to do anything here as the MessageBox is closed automatically.
}

The reason your whole application shuts down is because this relates to the class you're currently in. I'm guessing that class is your main Form and when your main form is closed, the application shuts down.

GenericTypeTea