As OriginalGriff pointed out, you cannot manipulate individual MDI Child Windows with setting 'WindowState. And, I agree with his recommendation that you avoid using MDI. However, many people are still using MDI, and many students are given assignments to create MDI apps.
You can "work around" not being able to use 'WindowState like this:
Assume you have two MDI Child Forms: ChildForm1, ChildForm2
1. on ChildForm1 is a Button, 'button1: in the code for ChildForm1 you have a Public Property of Type Button that you expose:
namespace YourNameSpace
{
public partial class childForm1 : Form
{
public childForm1 ()
{
InitializeComponent();
ChildForm1Button = this.button1;
}
public Button ChildForm1Button { private set; get; }
}
}
In your MDI Parent Form:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace YourNameSpace
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private ChildForm1 childForm1 = new ChildForm1();
private ChildForm2 childForm2 = new ChildForm2();
private void Form1_Load(object sender, EventArgs e)
{
childForm1.MdiParent = this;
childForm2.MdiParent = this;
childForm1.ChildForm1Btn.Click += ChildForm1Btn_Click;
childForm1.Show();
}
private void ChildForm1Btn_Click(object sender, EventArgs e)
{
Rectangle rect = this.ClientRectangle;
rect.Inflate(-20, -20);
childForm2.Bounds = rect;
childForm2.Show();
childForm1.BringToFront();
}
}
}
Initially, 'childForm1 is shown. When the Button on 'childForm1 is clicked:
1. the client rectangle of the MDI Parent is recorded, and then "shrunk" by 20 pixels: the 'Inflate command will effectively both change the Location and Size of the Rectangle.
2. 'childForm2's Bounds are set to the changed Rectangle, 'rect.
3. 'childForm2 is shown
4. 'childForm1 is brought back to the front of the z-order.
You might consider making your MDI Child Forms have no Minimize, or Maximize, Controls, no Titles, no CloseBox, etc., if you want to have complete control or size, position, and z-order of child Forms. But, that's going to take some work.
Of course, you can take advantage of MDI's build-in facilities to tile child Forms in various ways by calling the this.Layout.Mdi() method in your code.