in Visual C++.Switch forms.

hi, I switch from Form1 to Form2 by the following code:

in Form1:

#pragma once
#include "Form2.h"
.
.

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Form2^ x = gcnew Form2();
x->ShowDialog();
this->Hide();

in Form2:

pragma once
#include "Form1.h"
.
.
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Form1^ y = gcnew Form1();
y->ShowDialog();
this->Hide();

but when I run it , it gives me error. how I can solve it??

thanks in advance.
Topic archived. No new replies allowed.