How to Change Background Color of MDI Form in Windows Application.

Here, I explain how to change the background color of MDI form in Windows application.

If we set property IsMdiContainer=True windows form then all the rest of form will open with in it.
Here, Basically the concept of Child and Parents, the MDI form will behave a parents of and rest of all are child of that Mdi form.

If you set IsMdiContainer=True  then you will not able to change the background color of windows forms.
If you want to change the background color of Mdi forms then you have to right below code in Page_Load event of Mdi forms.

 C# Code

 private void Form1_Load(object sender, EventArgs e)
{
foreach (Control ctl in this.Controls)
{
try
{
System.Windows.Forms.Control Mdi = (MdiClient)ctl;

Mdi.BackColor = System.Drawing.Color.DarkSeaGreen;
}
catch (Exception a)
{
}
}
}

VB Code

For Each ctl As Control In Me.Controls
Try
Dim Mdi As System.Windows.Forms.Control = CType(ctl,MdiClient)
Mdi.BackColor = System.Drawing.Color.DarkSeaGreen
Catch a As Exception

End Try
Next

Leave a Reply

Your email address will not be published. Required fields are marked *