How do I change the background on a MDI parent window?
The easy answer would be to set the background property of the form to whatever color but that doesnt work.
Printable View
How do I change the background on a MDI parent window?
The easy answer would be to set the background property of the form to whatever color but that doesnt work.
That's because you cannot see the background of the form because it is obscured by an MdiClient control. That's the grey area that you can see and what actually hosts the child forms. You are not supposed to access it directly so there is no member variable created. To get a reference to it you simply need to iterate over the Controls collection of the form until you find one that is an MdiClient.Code:public partial class Form1 : Form
{
private MdiClient childHost;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
foreach (Control ctl in this.Controls)
{
if (ctl.GetType() == typeof(MdiClient))
{
// This is the control that hosts the child forms.
this.childHost = (MdiClient)ctl;
break;
}
}
}
}
if you go way back to page 4 in the vb.net codebank, you will find an example of creating custom mdi background colours.
it's in vb.net, but very easy to translate over to C#.
the link is ... Custom Background Colours in MdiForm / MdiChild. :)
Perfect. Thanks alot guys