Mdi的父母形式只有一次,它是第二次打开儿童表格而不是 [英] Mdi parent form only one time it is opening the child forms for the second time its not

查看:47
本文介绍了Mdi的父母形式只有一次,它是第二次打开儿童表格而不是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中我有两种形式通过使用Mdi形式我连接这两种形式与mdi形式它是连接的,问题是一旦打开子表单,如果用户关闭,下次不是为了两者都形成了我的代码在第一种形式的mdi父形式中的问题

Private Sub EmployeeToolStripMenuItem_Click(sender As System.Object,e As System.EventArgs)处理EmployeeToolStripMenuItem.Click

如果f2什么都没有那么

f2 =新Empform()

f2.MdiParent =我



f2.Show()

Else

f2.Activate()

结束如果



End Sub

为第二张表格

如果f3什么都没有那么

f3 =新派对()

f3.MdiParent =我

f3.Show()

结束如果

In My project i am having two forms By using Mdi form i am connected those two forms with mdi form It is connected and the problem is once a child form opened and if closed by user and the next time it was not for the both forms what is the problem this my code in mdi parent form of first form
Private Sub EmployeeToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles EmployeeToolStripMenuItem.Click
If f2 Is Nothing Then
f2 = New Empform()
f2.MdiParent = Me

f2.Show()
Else
f2.Activate()
End If

End Sub
for the second form
If f3 Is Nothing Then
f3 = New Party()
f3.MdiParent = Me
f3.Show()
End If

推荐答案

我是没有10确定你期望在这里发生什么,但是在这两种情况下你的代码只会创建每个表单的一个实例 - 它特别不会再创建一个新实例。



所以我猜测会发生的是:

因菜单点击而创建EmpForm。

使用EmpForm。

使用关闭EmpForm

用户再次点击菜单,没有显示新的EmpForm。



类似于你的派对表格。



如果是这种情况,那么当您创建表单时,需要为FormClosed事件添加处理程序,并在触发该事件时,将f2(或f3作为相关)设置为Nothing。

这样第二次单击菜单项时,代码将能够再次创建一个新实例。



如果不是那就是,那么你需要更准确地解释你想要实现的目标以及它给你的问题。
I'm not entirely sure what you are expecting to happen here, but your code in both cases will only create one instance of each form - it specifically doesn't create a new instance ever again.

So I'm guessing that what happens is:
Create EmpForm as result of menu click.
Use EmpForm.
Use closes EmpForm
User clicks menu again, no new EmpForm is displayed.

And similarly for your Party form.

If that's the case, then when you create your form, you need to add a handler for the FormClosed event and when that event is fired, you set f2 (or f3 as relevant) to Nothing.
That way the second time the menu item is clicked, the code will be able to create a new instance again.

If it isn't that, then you need to explain in better detail exactly what you are trying to achieve and what problem it is giving you.


这篇关于Mdi的父母形式只有一次,它是第二次打开儿童表格而不是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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