I having trouble going back to form1 from form2.
What i'm trying to do:
form1 takes you to form2 when button is click and
form2 takes you to form1 when button is click.
I tried changing this->Visible = false;
to this->Close();
on both forms and i get this error
1>c:\users\form2.h(172): error C2065: 'form1' : undeclared identifier
1>c:\users\form2.h(172): error C2065: 'go_form1' : undeclared identifier
1>c:\users\form2.h(172): error C2061: syntax error : identifier 'menu_form'
1>c:\users\form2.h(173): error C2065: 'go_form1' : undeclared identifier
1>c:\users\form2.h(173): error C2227: left of '->Show' must point to class/struct/union/generic type
Form 1
#include "form2.h"
private: System::Void start_button_Click(System::Object^ sender, System::EventArgs^ e) {
form2^ go_form2 = gcnew form2();
go_form2->Show();
this->Visible = false;
}
Form 2
#include "form1.h"
private: System::Void start_button_Click(System::Object^ sender, System::EventArgs^ e) {
form1^ go_form1 = gcnew form1();
go_form1->Show();
this->Visible = false;
}
Edit: I tried doing this C++/CLI - how to open a new form and back Now it opens second form but in small window with nothing on it
Form2
public ref class Form2 : public System::Windows::Forms::Form
{
public:
Form2(void)
{
InitializeComponent();
}
public:
Form2(System::Windows::Forms::Form ^ form1)
{
otherform = form1;
InitializeComponent();
}
private: System::Windows::Forms::Form ^ otherform;
private: System::Void Button_Click(System::Object^ sender, System::EventArgs^ e) {
this->Hide();
otherform->Show();
}
Form1
private: System::Void button_Click(System::Object^ sender, System::EventArgs^ e) {
Form2^ go_form2 = gcnew Form2(this);
go_form2->Show();
this->Hide();
}
I got it work now. I had commented out InitializeComponent();
in my constructor