gpt4 book ai didi

c# - 如何在不在 C# Windows 应用程序中创建父类的新实例的情况下返回父窗体

转载 作者:太空宇宙 更新时间:2023-11-03 15:52:29 25 4
gpt4 key购买 nike

如何在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com