更新时间:2023-12-06 15:36:04
你有一个主表单,其中正在加载多个聊天表单...
现在,在该主表单中,
采取页面级变量
you have a main form inside which multiple chat forms are loading...
now,in that mainform,
take page level variable
List<int> openedchats = new List<int>(); </int></int>
现在,当在计时器上打开表单时
now, when open form on timer
if (!openedchats.Contains(userId))
{
openedchats.add(userId);
frmchat c = new frmchat();
c.Tag = userId;
c.Parent = this;
c.show();
}
else
{
//nothing to do
}
以父表格添加方法......
Add method... in parent form
public void RemovefromOpenedchats(int userid)
{
openedchats.Remove(userId);
}
和 frmchat 形式
in form_closing 事件
and in frmchat form
in form_closing event
(MainForm)this.Parent.RemovefromOpenedchats((int)this.Tag);
快乐编码!
:)
Happy Coding!
:)
目前还不是很清楚你的意思。但只需引用表单并检查它是否不是null
或if(form.Visible)
。您还可以在打开计时器外部的表单时取消计时器。
祝你好运!
It's not very clear what you mean exactly. But simply have a reference to the form and check it isn'tnull
orif(form.Visible)
. You can also cancel the timer when opening a form outside of the timer.
Good luck!