Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I make a child Form fill the entire MDI client without being maximized?

Here is how it can be done. This takes into account all docked controls (including menus) in the mdi parent form.

[C#]

private void FillActiveChildFormToClient() 
{ 
  Rectangle mdiClientArea = Rectangle.Empty; 
  foreach ( Control c in  Controls ) 
    if (c is MdiClient ) mdiClientArea = c.ClientRectangle; 

  ActiveMdiChild.Bounds = mdiClientArea; 
}

[Visual Basic]

Private Sub FillActiveChildFormToClient()
  Dim mdiClientArea As Rectangle = Rectangle.Empty
  Dim c As Control
  For Each c In Controls
    If TypeOf c Is MdiClient Then
      mdiClientArea = c.ClientRectangle
    End If
  Next
  ActiveMdiChild.Bounds = mdiClientArea
End Sub 

Contributed from George Shepherd's Windows Forms FAQ



Page view counter