I think what you are seeing is the MdiiClient area background on loading the
form.
Load the two forms below that set the MdiClient background to
ControlLightLight and see if this is what you are looking for..
//************ MDI FORM ********************
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace MjbMdiDoubleBuffer
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.SetStyle( ControlStyles.AllPaintingInWmPaint
| ControlStyles.ResizeRedraw
| ControlStyles.DoubleBuffer
| ControlStyles.UserPaint
,true);
}
[DefaultValue(false)]
public new bool IsMdiContainer
{
get{ return base.IsMdiContainer; }
set
{
base.IsMdiContainer = value;
if( ! value) return;
for(int i = 0; i < this.Controls.Count; i++)
{
MdiClient mdiClient = this.Controls as MdiClient;
if(mdiClient != null)
{
ControlStyles styles = ControlStyles.DoubleBuffer;
try
{
// Prevent flickering, only if our assembly
// has reflection permission.
Type mdiType = typeof(MdiClient);
System.Reflection.BindingFlags flags =
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance;
System.Reflection.MethodInfo method
= mdiType.GetMethod("SetStyle",flags);
object[] param = {styles, true};
method.Invoke(mdiClient,param);
}
catch ( System.Security.SecurityException)
{
/*Don't do anything!!! This code is running under
partially trusted context*/
}
mdiClient.Paint +=new PaintEventHandler(this.MdiClient_Paint);
mdiClient.Resize +=new EventHandler(MdiClient_Resize);
break;
}
}
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.Text = "Add Child";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Form1";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void menuItem1_Click(object sender, System.EventArgs e)
{
Form2 form = new Form2();
form.MdiParent = this;
form.Show();
}
private void MdiClient_Resize(object sender, EventArgs e)
{
((MdiClient)sender).Invalidate();
}
private void MdiClient_Paint(object sender, PaintEventArgs e)
{
MdiClient mdiClient = ((MdiClient)sender);
Brush brush = new SolidBrush(SystemColors.ControlLightLight);
e.Graphics.Clip = new Region(mdiClient.ClientRectangle);
e.Graphics.FillRectangle(brush,mdiClient.ClientRectangle);
brush.Dispose();
}
}
}
//*********************** MdiChild Form ****************
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace MjbMdiDoubleBuffer
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox5;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form2()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.SetStyle( ControlStyles.AllPaintingInWmPaint
| ControlStyles.ResizeRedraw
| ControlStyles.DoubleBuffer
| ControlStyles.UserPaint
,true);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// radioButton1
//
this.radioButton1.Location = new System.Drawing.Point(16, 16);
this.radioButton1.Name = "radioButton1";
this.radioButton1.TabIndex = 0;
this.radioButton1.Text = "radioButton1";
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(16, 40);
this.radioButton2.Name = "radioButton2";
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "radioButton2";
//
// radioButton3
//
this.radioButton3.Location = new System.Drawing.Point(16, 72);
this.radioButton3.Name = "radioButton3";
this.radioButton3.TabIndex = 2;
this.radioButton3.Text = "radioButton3";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(120, 24);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(144, 20);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "textBox1";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(120, 56);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(144, 20);
this.textBox2.TabIndex = 4;
this.textBox2.Text = "textBox2";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(120, 88);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(144, 20);
this.textBox3.TabIndex = 5;
this.textBox3.Text = "textBox3";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(120, 120);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(144, 20);
this.textBox4.TabIndex = 6;
this.textBox4.Text = "textBox4";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(120, 152);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(144, 20);
this.textBox5.TabIndex = 7;
this.textBox5.Text = "textBox5";
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.textBox5);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.radioButton3);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
}
#endregion
bool firstPaint = true;
protected override void OnPaint(PaintEventArgs e)
{
if (firstPaint)
{
e.Graphics.Clip = new Region(this.Bounds);
e.Graphics.Clear(SystemColors.Control);
firstPaint = false;
}
base.OnPaint (e);
}
}
}