如何从一种形式回到另一种形式 [英] How to go back from one form to other
问题描述
大家好,
我对C ++/CLI编程是相当陌生的.在我的项目中,我有一个主要形式.当我单击它上的按钮时,我会隐藏此表单并显示其他表单.这很好.我使用的代码是
hi guys,
i am fairly new to c++/cli programming. In my project i have a main form. when i click a button on it i hide this form and show other form. this is working fine. The code i used is
weatherfrm^ weather = gcnew weatherfrm();
this->Hide();
weather->ShowDialog();
现在我想做的是,当我单击第二个表单上的按钮时,我想再次显示第一个表单并关闭此表单.我能够关闭第二种形式,但是我找不到显示第一种形式的方法,因为我无法在第二种形式上创建第一种形式的实例.这样做的原因是,我在第一个中包含第二种形式weather.h,但是现在我不能对主形式做同样的事情,因为文件不能互相包含.
有人可以帮我吗?
now what i want to do is when i click the button on the second form i want to show the first form again and close this form. i am able to close the second form but i cant find a way to show the first form as i cannot create an instance veriable of first form on the second form. The reaon for this is that i include the second form weather.h in the frst one but now i cant do the same for the mainform as the files cannot include each other.
can someone plz help me.
推荐答案
您可以使用方法ShowDialog()
显示第二个表单,此调用将显示该表单,直到该表单为关闭.然后,要再次显示主要表单,只需在下面的行中添加this->Show()
:
You show the second form using the methodShowDialog()
, this call show the form and doesn''t return until the form is closed. Then to show again the main form, you have to just addthis->Show()
on the line below:
weatherfrm^ weather = gcnew weatherfrm();
this->Hide();
weather->ShowDialog();
this->Show();
这篇关于如何从一种形式回到另一种形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!