Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6184561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:33:29+00:00 2026-05-24T01:33:29+00:00

I am using C# here. I have a form where the user can select

  • 0

I am using C# here. I have a form where the user can select Yes or No, and if they choose No, a message box appears and asks them if they are sure. If they click No, I want to show the form again. Here’s my code:

public void function()
{
    MyForm form = new MyForm();
    if (form.ShowDialog() == DialogResult.No)
    {
        if (MessageBox.Show("Are you sure?",
                            MessageBoxButtons.YesNo) == DialogResult.Yes)
        {
            runFinished.Dispose();
            return;
        }
        else
        {
            //Show form again. How??
        }
    }
}

Thanks everybody for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:33:30+00:00Added an answer on May 24, 2026 at 1:33 am

    Arrange that the No button MyForm does the call to MessageBox. Only if the user is sure do you then go on to close the dialog. Your current approach of asking the question after the dialog has closed is incorrect.

    You can effect the change by making sure that DialogResult is set in code rather than by the No button’s DialogResult property. Then in the click handler for the button you run the message box. If the user confirms the action, then set the forms DialogResult to DialogResult.No.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form where a user can add multiple select boxes for multiple
I have a new batch form where user can select books from a div
I have a combobox on a web form. The user can select a single
Does anyone have experience using the URL Rewrite Module (see here )? Can it
I have some code that is using SyncEnumerator. As you can see here ,
I have a problem I can not resolve on a form Here's my view:
I have HTML form with lots of select and input fields, using it a
Here I have an arbitrary IEnumerable<T> . And I'd like to page it using
I have read the post here about using setTimeout() during intensive DOM processing (using
Using Rational ClearCase v. 7.0.1.1 with UCM, I have a problem here when using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.