RSS

MDI Parent background color

15 Mar

The reason you are having this problem is because when you turn a form into an MdiParent you are also having an MdiClient object  added on your behalf that doesn’t show up in your code. When you change the BackColor of the form, any change are hidden by the MdiClient that is taking up all of the area where your desired BackColor is actually being displayed.

To fix this… we need to enumerate through the controls on the form to find the MdiClient, once we’ve found it, we change it’s BackColor ala:

 

foreach (Control c in this.Controls)
{
if( c is MdiClient)
c.BackColor = Color.Red;
}

 

For System Colors Change MDI Background Color

 

private void frmMDIParent_Load(object sender, EventArgs e)
{

foreach (Control c in this.Controls)
{
if (c is MdiClient)
c.BackColor = SystemColors.GradientInactiveCaption;
}
}

Advertisements
 
Leave a comment

Posted by on March 15, 2013 in WinForm

 

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: