如果我的用户点击了一个按钮,我想发布一个新的表单。 然后,当用户关闭第二个表单时,我想返回初始表单。
var appLaunch = new App();
appLaunch.Show();
this.Hide();
有人可以帮帮我吗?当我关闭第二张表格时,我的代码不允许我返回到我离开的地方
答案 0 :(得分:3)
要创建新表单appLaunch
,您可以使用:
var appLaunch = new App();
appLaunch.Show(this);
this.Hide();
然后在appLaunch
FormClosed
事件中添加此代码
private void appLaunch_FormClosed(Object sender, FormClosedEventArgs e) {
this.Owner.Show();
}
答案 1 :(得分:0)
hide()
功能只是暂时从显示中删除表单。
close()
函数从内存中删除了表单。
因此,如果您想在显示form2后返回到form1,请不要close
form1。你可以hide
,但你不必这样做。当您想要返回form1时,只需hide
form2。