在C#Windows应用程序中关闭特定表单的代码 [英] code for closing particular form in c# windows application
本文介绍了在C#Windows应用程序中关闭特定表单的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要用于在Windows应用程序(C#)中关闭特定表单的代码....
I need code for closing particular form in windows application(C#).......
推荐答案
Try:
Try:
myForm.Close();
其中myForm
是变量,其中包含您要关闭的表单的实例. IE.在创建表单实例时,请将其保存在myForm
:
Where myForm
is teh variable holding teh instance of the form you wish to close. I.e. when you cretaed teh form instance, save it in myForm
:
FormIWantToClose myForm = new FormIWantToClose();
...
myForm.Show();
...
myForm.Close();
尝试以下方法:
Try These:
private void button1_Click(object sender, EventArgs e)
{
myForm frm = new myForm();
this.Close();
}
或:
or:
private void button1_Click(object sender, EventArgs e)
{
myForm frm = new myForm();
frm.Close();
}
希望对您有帮助:)
hope it helps :)
如果您要通过名称搜索特定表格,可以使用
System.Windows.Forms.Application.OpenForms
找到您想要的那个,然后调用Close.
If you''re searching for a particular form by name you could use
System.Windows.Forms.Application.OpenForms
Find the one that you want and call Close.
这篇关于在C#Windows应用程序中关闭特定表单的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文