Hi I have a mdi child form (form A) which when clicked displays another mdi child formn(form B) both of which share the same parent form. The problem is I cant find a way to center the child form B to child form A? Is this even allowed in vb.net? I can however display form B (as a non mdi child) centered to form A (as a mdi child form) which is strange. an though this could work this issue now is that the forms boarder within Windows 8 at least, is visually totally different to a mdi form in windows 8 making the whole thing look un-uniformed and messy?
Here's one way to accomplish it:
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