如何在 C# Windows 应用程序中不创建父窗体的新实例就返回到父窗体? 我已经尝试过 this.Parent、this.MdiParent、this.MyParentForms,但没有人成功。
最佳答案
您的父表单中可以有一个按钮,用于显示另一个表单。将此代码添加到按钮的 Click 事件中:
//Click event of your button.
private void goToSecondForm_Click(object sender, EventArgs e)
{
this.Hide(); //Hides the parent form.
subform.ShowDialog(); //Shows the sub form.
this.Show(); //Shows the parent form again, after closing the sub form.
}
关于c# - 如何在不在 C# Windows 应用程序中创建父类的新实例的情况下返回父窗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25222547/