Reputation: 3
I have 2 forms Form1 and Form2. How can I, inside code (Form1.h) show Form2 (something like Form2::Show())
Upvotes: 0
Views: 6568
Reputation: 942197
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);
}
Upvotes: 3
Reputation: 888047
You need to create a new instance of the Form2
class and call its Show()
method.
Upvotes: 1