Thursday, September 10, 2009

Change the MDI child form’s background color when MDI parent clicks

When you create a form as a MDI child , sometimes you want to access the form object to do some modification from MDI parent. Using following mechanism you can change any associate property of the form.

here is a example of changing MDI child’s form background color when MDI parent menu clicks.

private void MDIToolStripMenuItem_Click(object sender, EventArgs e)
{
    Control[] CC = this.Controls.Find("Form1",true);
    foreach (var item in CC)
    {
        if (item.GetType().Name=="Form1" )
        {
            Form1 F = (Form1)item;
            F.BackColor = Color.Aqua;
        }
    }
}
Post a Comment