0
votes

I have a MDI Child form (frmReview) that I aim to show on my maximized parent form with the following code:

Public Sub frmTransport_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    'keyboard shortcuts
    If e.KeyCode = Keys.F1 Then LaunchManual()
    If e.Control Then
        If e.KeyValue = Keys.R Then
            Me.WindowState = FormWindowState.Maximized
            Dim review As New frmReview
            review.MdiParent = Me
            review.Location = New Point(1175, 0)
            review.BringToFront()
            review.Show()
        End If
        ...
        ...
        End Sub

enter image description here

The point (1175, 0) is the top-right corner where the TabControl meets the Yellow mdi Container. The parent form has its isMdiContainer property set to True and Load event of frmReview does fire when i run this code, but I do not see the child form:

In another program I have, I use to same process to display MDI Child Forms and it works fine. Any suggestions on why this is happening?

Thanks in advance!

1
You know that Location corresponds to the top left corner of a control, and you are setting that to the top right corner of the parent? Try (588, 0), it should be in the middle. You just need to do the math for the proper locationdjv
My mistake - set it to (588, 0), still not workingTyler Braun

1 Answers

1
votes

If you want to display the form in the top right corner, use this

Dim mdiClient = Me.Controls.OfType(Of MdiClient).FirstOrDefault()
Me.WindowState = FormWindowState.Maximized
Dim review As New frmReview
review.MdiParent = Me
review.BringToFront()
review.Show()
' order of Show() call changed so review has a size
review.Location = New Point(mdiClient.Size.Width - review.Width, 0)