Search code examples
vb.netmdichildmdiparent

How to position MDIChild form in bottom right corner of MDIParent?


Looks like a dumb question, but I tried the following (where "Me" is a MDIParent form):

Dim frmNotif As New frmNotifica
With frmNotif
  .MdiParent = Me
  .StartPosition = FormStartPosition.Manual
  .Location = New Point(ClientSize.Width - .Width, ClientSize.Height - .Height)
  .Show()
End With

but it doesn't work.

Ideas?


Solution

  • Assuming you have an "empty" MDI Parent form (no Panels or ToolStrips docked), this should work:

    Dim frmNotif As New frmNotifica
    With frmNotif
      .MdiParent = Me
      .StartPosition = FormStartPosition.Manual
    
      Dim leftStart As Integer = Me.ClientSize.Width - (.Width + (SystemInformation.Border3DSize.Width * 2))
      Dim topStart As Integer = Me.ClientSize.Height - (.Height + (SystemInformation.Border3DSize.Height * 2))
    
      .Location = New Point(leftStart, topStart)
      .Show()
    End With
    

    If you have a Panel or a ToolStrip added to the MDIParent, you would have to factor that in to your equation, too.