在C#中仅打开Windows窗体一次 [英] Open Windows Form only once in C#

查看:47
本文介绍了在C#中仅打开Windows窗体一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何避免在c#中使用Windows窗体的多个实例

我只希望在应用程序中仅显示一次打开的表单,而不将其创建为MDI表单.

I want to show open form only once in an application without creating them as MDI form.

推荐答案

在从代码中打开表单之前,请检查

Before opening the form from your code, check the Application.OpenForms property and see if the form exists in the collection.

类似的东西:

if ((Application.OpenForms["Form1"] as Form1) != null)
{
 //Form is already open
}
else
{
// Form is not open
}

这篇关于在C#中仅打开Windows窗体一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆