本文介绍了如何检查是否opned窗口关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我工作的 C#的WinForms
我有功能验证()
这是目前在CS文件。当我打电话功能验证()
它打开ErrorForm使用
I have function Validate()
which is present in the CS file. When i call function Validate()
it opens ErrorForm using
ErrorForm ew = new ErrorForm(Errors); // Errors is list<string>
ew.Show();
但是,当我再次调用它,新窗口openes和我以前的窗口打开too.I得手动关闭该窗口。
But when i call it again, new window openes and my previous window is open too.I have to close that window manually.
有没有使用它,如果我称之为的validate()
再次,它会关闭任何方法电流 ErrorForm
键,会打开新的 ErrorForm
。
Is there any method using which if i call validate()
again, it will close current ErrorForm
and will open new ErrorForm
.
推荐答案
试试这个:
var f1=Application.OpenForms["ErrorForm"];
if(f1!=null)
f1.Close();
f1= new ErrorForm(Errors);
f1.Show();
这篇关于如何检查是否opned窗口关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!