You can just set the Padding
of your Mdi
form. The padding is the distance between the control (as a container) and its child controls. There are 4 sides: left, top, right, bottom. This code just makes all the sides the same:
Padding = new Padding(50);
You can notice that the BackColor
around the MdiClient
is not affected. To affect the BackColor
around the MdiClient
, we have to override the OnPaint
so that the default behavior is not processed:
BackColor = Color.Green;//try setting the BackColor of the Mdi form to Color.Green
protected override void OnPaint(PaintEventArgs e){
RaisePaintEvent(this, e); //remove the base.OnPaint(e)
}
If you want to take full control over the MdiClient
, just declare a variable to hold the MdiClient
:
MdiClient client = Controls.OfType<MdiClient>().First();
Then you can use its Properties
and methods
like as you do on a form, such as client.Dock = DockStyle.Left
, client.Width = 400;
, ...