【发布时间】:2021-07-15 06:48:24
【问题描述】:
我有两个单独的表格 list_of_students_page 和 testing。
我在 list_of_students_page 中有一个按钮,点击它会打开测试表格。我在测试表单中创建了一个按钮以返回 list_of_students_page。
在测试表单中运行按钮时,单击两次即可工作。
我在 Visual Studio 中使用 C++/CLI Windows 窗体。
list_of_students_page.h
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
CppCLR_WinformsProjekt1::testing^ testing_f = gcnew CppCLR_WinformsProjekt1::testing;
this->Hide();
testing_f->ShowDialog();
if (testing_f->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
this->Show();
}
}
测试.h
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
this->DialogResult = System::Windows::Forms::DialogResult::OK;
this->Close();
}
为什么会发生这种情况,我应该如何解决这个问题?
【问题讨论】:
-
删除 Close() 调用,分配 DialogResult 属性即可关闭对话框。
标签: c++ visual-studio winforms visual-c++ c++-cli