简体   繁体   English

我如何以全屏方式从另一个MDI子打开MDI子-在父窗体中

[英]How Can I Open MDI Child From Another MDI Child At Fullscreen - Inside Parent Form

I am working with an MDI application and I want to know what is the best way to open child forms of child forms in the main window at fullscreen? 我正在使用MDI应用程序,我想知道在全屏主窗口中打开子窗体的子窗体的最佳方法是什么? Some of these child forms are created from instances, so I don't know how to refer to the parent each time I open an instance. 其中一些子窗体是从实例创建的,因此我不知道每次打开实例时都如何引用父窗体。

For example, I have my main Parent form (frmMain). 例如,我有我的主要父母形式(frmMain)。 I then open a child form (Form2) using the following code: 然后,我使用以下代码打开子窗体(Form2):

frmMain: frmMain:

Dim frm As New Form2
frm.MdiParent = Me
frm.WindowState = FormWindowState.Maximized
frm.Show()

Form2: 表格2:

Private Sub frmAssetTracker_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    fMain = DirectCast(Me.MdiParent, frmMain)

    Me.MaximizeBox = False
    Me.WindowState = FormWindowState.Normal
    Me.WindowState = FormWindowState.Maximized
End Sub

This works fine and gives me a fullscreen child inside the parent form. 这可以正常工作,并且在父表单中给了我一个全屏显示的孩子。 However, how do I then open a child of Form2 at fullscreen and so on? 但是,如何在全屏模式下打开Form2的子级,依此类推?

So, how would I open Form3 from Form2 using frmMain as the parent? 那么,如何使用frmMain作为父级从Form2打开Form3?

UPDATE My frmMain has a docked element at the top of the window to provide a button bar for the entire application. 更新我的frmMain在窗口顶部有一个停靠的元素,可为整个应用程序提供按钮栏。 When I open child forms from the Parent using my code below, it maximises the form around the docked element fine. 当我使用下面的代码从“父级”打开子级表单时,它将最大化停靠元素周围的表单。 However, when I try and open a child of a child form, it creates a 'jumping' effect as the form goes from normal state to maximized state. 但是,当我尝试打开子窗体的子窗体时,它会在窗体从正常状态变为最大化状态时产生“跳跃”效果。 If I remove Me.WindowState = FormWindowState.Normal , the child form sits behind the docked element of the Parent form. 如果删除Me.WindowState = FormWindowState.Normal ,则子窗体位于父窗体的停靠元素的后面。

Try Following Code In Form2 尝试在Form2中遵循代码

Dim frm As New Form3
frm.MdiParent = Me.MdiParent
frm.WindowState = FormWindowState.Maximized
frm.Dock=DockStyle.Fill
frm.Show()

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

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