显示来自单独班级的MDIChild [英] Show MDIChild from Seperate Class
问题描述
我有两种形式,一种是班级
第一个形式为frmMain
,并且MDIParent
设置为true.第二种形式是frmClientInfo
.班级是clsAction
在frmMain
上,当单击呼叫clsAction
时,我有一个菜单按钮.
我必须将frmClientInfo
从clsAction
加载到FrmMain
中.同时查看frmClientInfo
是否已经加载,如果激活,则将其激活,否则显示frmClientInfo
我知道如何在VB.NET中执行此操作..在C#中我可以绕过它
Thx
I have two forms and one Class
First Form is frmMain
and MDIParent
set to true. Second Form is frmClientInfo
. Class is clsAction
On frmMain
I have a menu button, when click calls clsAction
.
I have to load frmClientInfo
into FrmMain
from clsAction
. At the same time see if frmClientInfo
is already Loaded, if so just activate it, else show frmClientInfo
I know how to do this in VB.NET..just can my head around it in C#
Thx
推荐答案
我必须从clsAction将frmClientInfo加载到FrmMain中.
I have to load frmClientInfo into FrmMain from clsAction.
如果必须这样做,则需要在clsAction
类中引用frmClientInfo
和FrmMain
.一旦在类中具有引用,就可以始终在frmClientInfo
上设置MDIParent属性.
要回答第二部分,您可以从MDI表单中获取所有子表单的列表.这样您就可以遍历该集合并检查所需形式的类型是否不等于该循环的一部分.如果执行循环,并且发现没有任何表单与所需表单类型匹配,则可以自由创建所需表单的新实例并显示它.如果发现其中一种表单具有所需表单的类型,则只需激活它并中断循环即可.
希望你能理解.
If you have to do this, you need references of frmClientInfo
and FrmMain
into clsAction
class. Once you have references in the class, you can always set the MDIParent property on frmClientInfo
.
To answer the second part, you can get list of all child forms from a MDI form. In that you can loop through the collection and check whether the type of the desired form is not equal to the one which is part of the loop. If the loop executes and you find that none of the forms match the desired form type, you are free to create a new instance of the desired form and display it. If you find that one of the forms has the type as that of the desired form, you just activate it and break the loop.
Hope you understood.
这篇关于显示来自单独班级的MDIChild的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!