如何关闭当前窗口? [英] how can i close current window ?
本文介绍了如何关闭当前窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友
我想在单击按钮时关闭当前窗口,然后打开另一个窗口.
我在按钮单击上使用下面给出的代码
<pre lang="midl">Form1 f = new Form1();<br /> f.Show();</pre><br /> <br /> <br /> <pre lang="midl">Form2 f2 = new Form2();<br /> f.Close();</pre><br /> <br />
但它不起作用,我也在使用hide,但它不起作用,有谁能帮助我
解决方案
回答您的问题:
Form1 f = 新 Form1(); f.关闭+ = 新.... f.ShowDialog();
并且在Form1的Closed
事件处理程序中
Form2 f = 新 Form2(); f.ShowDialog();
也许如果您确切地描述了您要执行的操作,我们可以为您提供更好的答案.
在单击form1的按钮上单击即可关闭当前窗口:
this.Close();
并写下来打开新窗口:
Form2 f2 = new Form2(); f2.ShowDialog();
希望这对您有所帮助:)
C#Apps中的多个后续主"表单 [ ^ ]
hello friend
i want close the current window when i am click on button and open another window.
i am using code on button click which is given below
<pre lang="midl">Form1 f = new Form1();<br /> f.Show();</pre><br /> <br /> <br /> <pre lang="midl">Form2 f2 = new Form2();<br /> f.Close();</pre><br /> <br />
but its not working i am use hide also but its not working can any one help me
解决方案
To answer your question:
Form1 f = new Form1(); f.Closed += new .... f.ShowDialog();
and in theClosed
event handler for Form1
Form2 f = new Form2(); f.ShowDialog();
Maybe if you described EXACTLY what you''re trying to do, we could give you a better answer.
on button click of form1 code this to close the current window:
this.Close();
and write this to open the new window:
Form2 f2 = new Form2(); f2.ShowDialog();
hope this helps :)
After your response to Ace_Hardlight, I think this tip/trick will help you:
Multiple Subsequent "Main" Forms in C# Apps[^]
这篇关于如何关闭当前窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文