How do I make my 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()
{
Form child = this.ActiveMdiChild;
Rectangle mdiClientArea = Rectangle.Empty;
foreach(Control c in this.Controls)
{
if(c is MdiClient)
mdiClientArea = c.ClientRectangle;
}
child.Bounds = mdiClientArea;
}



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

0 comments :

Post a Comment