MDI (Multiple Document Interface) Set Background Image
To change the background color of a parent MDI form is to set the background color property. However, it seems to ignore it. Also some of us hate the dark gray background.
In this tutorial I will help you to programmatically set the Background Image of the MDI parent. This includes vs2003 & vs2005 c# source file.
VS2003 C#
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private string filepath = System.Environment.CurrentDirectory;
private void Form1_Load(object sender, System.EventArgs e)
{
filepath = System.IO.Path.Combine (filepath, "Desert.jpg");
foreach(Control cntrl in this.Controls)
{
if ((cntrl.GetType() == typeof(System.Windows.Forms.MdiClient ))){
cntrl.BackgroundImage = Image.FromFile(filepath);
}
}
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
Form frmChild = new Form();
frmChild.MdiParent = this;
frmChild.Text = "Hello, im a child form";
frmChild.Show ();}VS2005 C# - applicable to VS2008
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MdiApplicationCS2005
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
foreach (Control cntrl in this.Controls)
{
if (cntrl is MdiClient)
{
cntrl.BackgroundImage = Properties.Resources.Jellyfish;
}
}
}
private void childToolStripMenuItem_Click(object sender, EventArgs e)
{
Form frmChild = new Form();
frmChild.MdiParent = this;
frmChild.Text = "Hello i'm a child form";
frmChild.Show();
}
}
} 



