我有一个MDI子表单(frmReview),我的目标是在我的最大化父表单上显示以下代码:
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
点(1175,0)是TabControl与黄色mdi容器相遇的右上角。父表单的isMdiContainer属性设置为True,当我运行此代码时,frmReview的Load事件会触发,但我看不到子表单:
在我的另一个程序中,我使用相同的过程来显示MDI子窗体,它工作正常。有关为何发生这种情况的任何建议?
提前致谢!
答案 0 :(得分:1)
如果要在右上角显示表单,请使用此
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)