I have a message Box with two options, Retry or Cancel. Upon clicking cancel, I want to close the MessageBox and then load the main Form. Any idea how to do that? This function is already within a button_click function and I want to get out of this function and back to the Form_load.

void button_click(...)
{

dr=MessageBox.Show(.....);
if(dr== DialogResult.Cancel)
//exit the button and go back to the main form

}

I have a message Box with two options, Retry or Cancel. Upon clicking cancel, I want to close the MessageBox and then load the main Form. Any idea how to do that? This function is already within a button_click function and I want to get out of this function and back to the Form_load.

void button_click(...)
{

dr=MessageBox.Show(.....);
if(dr== DialogResult.Cancel)
//exit the button and go back to the main form

}

Check out this
http://dotnetperls.com/messagebox-show
Hope its can help you...

I have a message Box with two options, Retry or Cancel. Upon clicking cancel, I want to close the MessageBox and then load the main Form. Any idea how to do that? This function is already within a button_click function and I want to get out of this function and back to the Form_load.

void button_click(...)
{

dr=MessageBox.Show(.....);
if(dr== DialogResult.Cancel)
//exit the button and go back to the main form

}

The MessageBox call works fine in the Form_Load method. If you are wanting to cancel that form's creation at that point to return to the calling form (main form?), you can call Close() method after checking DialogResult.Cancel .

This question has already been answered. Start a new discussion instead.