1

I'm trying to make my parent form MDI workarea to adjust from the child form size..

I have this code

Child.MdiParent = Me
Child.Show()
Me.Size = New Size(Child.Width, Child.Height)

but it resize the whole parent form. showing some scrollbars in the MDI workarea.

Parent size: H:400, W: 800

Parent mdisize. H:350, W:800 .. theres 50 because i have custom title bar. docked at top.

Child size: H:200, W: 400

Now i want the parent size to H:250, W:400... but it shows scrollbars means that its not perfectly fitted. need help guys...

zmbq
  • 38,013
  • 14
  • 101
  • 171
Joshua Belarmino
  • 546
  • 9
  • 24

1 Answers1

1

Someone else may have a better suggestion, but the way I've always done this is by calculating the difference between the parent form's client size and it's actual size:

Dim nonClientWidth As Integer = Me.Size.Width - Me.ClientSize.Width
Dim nonClientHeight As Integer = Me.Size.Height - Me.ClientSize.Height
Me.Size = New Size(Child.Width + nonClientWidth, Child.Height + nonClientHeight)
Steven Doggart
  • 43,358
  • 8
  • 68
  • 105