mdi 子窗体不会以同一父项中的另一个 mdi 子窗体为中心吗?
mdi child form wont center to another mdi child form within the same parrent?
您好,我有一个 mdi 子窗体(窗体 A),单击它会显示另一个 mdi 子窗体(窗体 B),它们共享相同的父窗体。问题是我无法找到一种方法将子表单 B 集中到子表单 A?这甚至在 vb.net 中被允许吗?但是,我可以显示以表单 A(作为 mdi 子表单)为中心的表单 B(作为非 mdi 子表单),这很奇怪。尽管这可以解决这个问题,但现在这个问题是 Windows 8 中的表单寄宿生在视觉上与 windows 8 中的 mdi 表单完全不同,使整个事情看起来不统一和混乱?
这是实现它的一种方法:
Public Class MdiChildA
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim childB As New MdiChildB
childB.MdiParent = Me.MdiParent
AddHandler childB.Load, AddressOf child_Load
childB.Show()
End Sub
Private Sub child_Load(sender As Object, e As EventArgs)
Dim otherChild As Form = DirectCast(sender, Form)
otherChild.StartPosition = FormStartPosition.Manual
otherChild.Location = New Point((Me.Location.X + Me.Size.Width / 2) - otherChild.Size.Width / 2,
(Me.Location.Y + Me.Size.Height / 2) - otherChild.Size.Height / 2)
End Sub
End Class
您好,我有一个 mdi 子窗体(窗体 A),单击它会显示另一个 mdi 子窗体(窗体 B),它们共享相同的父窗体。问题是我无法找到一种方法将子表单 B 集中到子表单 A?这甚至在 vb.net 中被允许吗?但是,我可以显示以表单 A(作为 mdi 子表单)为中心的表单 B(作为非 mdi 子表单),这很奇怪。尽管这可以解决这个问题,但现在这个问题是 Windows 8 中的表单寄宿生在视觉上与 windows 8 中的 mdi 表单完全不同,使整个事情看起来不统一和混乱?
这是实现它的一种方法:
Public Class MdiChildA
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim childB As New MdiChildB
childB.MdiParent = Me.MdiParent
AddHandler childB.Load, AddressOf child_Load
childB.Show()
End Sub
Private Sub child_Load(sender As Object, e As EventArgs)
Dim otherChild As Form = DirectCast(sender, Form)
otherChild.StartPosition = FormStartPosition.Manual
otherChild.Location = New Point((Me.Location.X + Me.Size.Width / 2) - otherChild.Size.Width / 2,
(Me.Location.Y + Me.Size.Height / 2) - otherChild.Size.Height / 2)
End Sub
End Class