我想创建多个表单,当我单击后退按钮时,它将返回到 form1。我尝试了这个 C++/CLI - 如何打开一个新表单并返回,但是当我单击 form2 中的按钮返回到 form1 时,它会出现错误。“ NullReferenceException 未处理”
表格1
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
/* Form1::Hide();
Form2^ form2 = gcnew Form2();
form2->ShowDialog();*/
Form2 ^ frm2 = gcnew Form2();
frm2->Show();
this->Hide();
}
表格2
Form2(System::Windows::Forms::Form ^ frm1)
{
otherform = frm1;
InitializeComponent();
}
private: System::Windows::Forms::Form ^ otherform;
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e
{
this->Hide();
otherform->Show();
}