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

}

if your main form is form1 then include


form1.Activeform.show();

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 .

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.