tags:

views:

25

answers:

2

Hi. I have 2 forms Form1 and Form2. How can I, inside code (Form1.h) show Form2 (something like Form2::Show())

+1  A: 

You need to create a new instance of the Form2 class and call its Show() method.

SLaks
Could you please post sample code? Thanks
+1  A: 

Edit your .cpp file and arrange the #include directives, putting the 2nd form first:

#include "stdafx.h"
#include "Form2.h"
#include "Form1.h"

Then write code like this in, say, a button's Click event handler:

    System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
        Form2^ frm = gcnew Form2;
        frm->Show(this);
    }
Hans Passant