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
2010-09-16 19:41:12
Could you please post sample code? Thanks
2010-09-16 19:42:25
+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
2010-09-16 19:52:25