限制我的表单不再打开一次 [英] Restrict my form to not open more then once

查看:61
本文介绍了限制我的表单不再打开一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(在按钮后面)



Read_QuranoTafsir readQuran = new Read_QuranoTafsir();

readQuran.Show();

readQuran.MdiParent = this;




这是我的新表单代码,它工作正常,但问题是

当我点击我的按钮时,会出现一个表格。

i再次单击另一个表单会出现这个事情继续,因为我一次又一次点击。

i想要限制我的表单如果表单已被激活则不能打开多于1。 br />
请帮助

(behind a button)

Read_QuranoTafsir readQuran = new Read_QuranoTafsir();
readQuran.Show();
readQuran.MdiParent = this;


This is my new form code it is working fine but the problem is
as i click my button a form appear.
i click again another form appear this thing continues as i click again and again.
i want to restrict my form to not open more then 1 if the form is alread active.
please HELP

推荐答案

两个简单的解决方案。



设置标志时打开表单,关闭时清除它。



在打开表单之前,检查标志是否已设置 - 因此表单已打开,并且你什么都不做如果未设置标志 - 您打开表单。



或者 - 在表单打开时禁用按钮,并在关闭时重新启用它。
Two simple solutions.

Set a flag when you open your form, clear it when you close.

Before you open your form, you check to see if the flag is set - hence the form is open, and you do nothing. If the flag is not set - you open the form.

Alternatively - disable button when the form opens, and reenable it when you close.


另一种选择是使它成为一个以null开头的字段。当用户单击该按钮时,检查该字段,如果为null,则实例化并设置该字段。问题是您需要在用户关闭表单时清除该字段。



还有其他涉及互斥量(mutices?)的解决方案。
Another option would be to make it a field which starts out null. When the user clicks the button, check the field, if null then instantiate and set the field. The problem being that you need to clear the field when the user closes the form.

There are other solutions involving mutexes (mutices?) as well.


这篇关于限制我的表单不再打开一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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