简体   繁体   English

需要从非MDI子窗体中打开MDI子窗体

[英]Need To Open An MDI Child Form From A Non MDI Child Form

I have the scenario where I am opening a form outside of an MDI parent using the following code: 我有使用以下代码在MDI父对象之外打开表单的情况:

Dim frm As New frmSpeedSearch
frm.Show(Me)

I then want the ability to open an MDI child from this frmSpeedSearch. 然后,我希望能够从此frmSpeedSearch中打开MDI子级。 FrmMain is the MDI Parent of all child forms. FrmMain是所有子窗体的MDI父窗体。 From the frmSpeedSearch, I make the following call: 在frmSpeedSearch中,我进行了以下调用:

Dim frm As New frmStorePage(_store)
frm.Owner = frmMain
frm.Show()

But this just opens the form normally. 但这只是正常打开表格。 How can I push this back into the MDI Parent container? 如何将其推回MDI父容器?
Within frmStorePage I make a call to the MdiParent which is failing because the form doesn't have an MDI Parent when I open it this way 在frmStorePage中,我对MdiParent进行了调用,但失败,因为以这种方式打开表单时,该表单没有MDI父级

Dim frm As frmDashBoard
frm = DirectCast(Me.MdiParent, frmMain)

Any suggestions would be appreciated, thanks. 任何建议,将不胜感激,谢谢。

You passed the MdiParent to frmSpeedSearch when you called Show(). 您在调用Show()时将MdiParent传递给frmSpeedSearch。

As such, you can do: 因此,您可以执行以下操作:

Dim frm As New frmStorePage(_store)
frm.MdiParent = Me.Owner
frm.Show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM