嗨,我有一个 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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句