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 7609385
In Process

The Archive Base Latest Questions

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

I am working a simple form, I spend more than a day to find

  • 0

I am working a simple form, I spend more than a day to find out something

What I want is to click a button in form1 and then pop up a form2. I have the following code

private: System::Void MyAdd_Click(System::Object^  sender, System::EventArgs^  e) {
         Form2^ myForm2 = gcnew Form2();

     }
};

However, the form2 could not pop up. I really don’t understand, so I copy more code from an example. Even though I don’t think it will be useful, just try. However it works.

private: System::Void MyAdd_Click(System::Object^  sender, System::EventArgs^  e) {
         Form2^ myForm2 = gcnew Form2();
         if (myForm2->ShowDialog()==System::Windows::Forms::DialogResult::OK) {}
     }
};

My question is that I have already created the form in both case, why the IF statement makes difference?

  • 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-31T01:09:34+00:00Added an answer on May 31, 2026 at 1:09 am

    In this case it makes no difference since nothing extra is done. However, a common usage is like so:

    void ShowMyDialogBox()
    {
       Form2^ testDialog = gcnew Form2;
    
       // Show testDialog as a modal dialog and determine if DialogResult = OK.
       if ( testDialog->ShowDialog( this ) == ::DialogResult::OK )
       {
    
          // Read the contents of testDialog's TextBox.
          this->txtResult->Text = testDialog->TextBox1->Text;
       }
       else
       {
          this->txtResult->Text = "Cancelled";
       }
    
       delete testDialog;
    }
    

    Checking the return value allows you to see how the dialog closed.

    If you are asking why you need to call ShowDialog, it is because even though you have created your form, you have not told the system to show it yet. Note that ShowDialog blocks/does not return until the dialog box is closed.

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

Sidebar

Related Questions

I'm trying to get a simple search form working in my RoR site. I've
I am working on a simple news module. There is a form where user
My javascript is not working right. It is simple pre-vailidation form and I can
Years back I built a simple mail form that has been working like a
I've been working on a simple JQuery dialog form that loads in via AJAX.
I'm working on a simple login form. When the user clicks on the Login
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
The simple working query, list the number of licenses for each license type: Query:
Working on a simple C program I'm stuck with an if test: int line_number
Working on a simple TimeTracker App. You start a timer, wait a certain time,

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.