As a C# programmer, you may have used Back Color property for changing the color of the background for control as well as Windows form. You can also found that this not works with MDI Parent form.
MDI is the container for child forms or control, actually, it’s inherited from the panel [leave it no…lol].
Ok, all you want to repaint all the controls in it, even though there are no controls were placed, think about the inherited panel. All we have to do is try to cast every control as MDIClient and loop through it and change the color as follows
MdiClient ctlMDI; // Loop through all of the form's controls looking // for the control of type MdiClient. foreach (Control ctl in this.Controls) { try { // Attempt to cast the control to type MdiClient. ctlMDI = (MdiClient)ctl; // Set the BackColor of the MdiClient control. ctlMDI.BackColor = Color.Gold; } catch (InvalidCastException exc) { // Catch and ignore the error if casting failed. } }
Place the code on Load Event of MDI Parent Form