简体   繁体   中英

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? 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). I then open a child form (Form2) using the following code:

frmMain:

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

Form2:

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?

So, how would I open Form3 from Form2 using frmMain as the parent?

UPDATE My frmMain has a docked element at the top of the window to provide a button bar for the entire application. 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.

Try Following Code In Form2

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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