Change child forms color according to MDI form's colordialog
I have a MDI parent form and several child form associated with it using menustrip. I take a colordialog control on toolstrip of MDI form. When I open it and select a color from it and press OK I want to assign that color to MDI Form and all it's Child form's background color. How can I do that?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sudhakar ChaudharyRank #1,379 · 1.2K reputationPosted Jan 16, 2013, 8:09 PM EST
Color clr;
private void toolStripButton1_Click(object sender, EventArgs e)
{
ColorDialog clDg = new ColorDialog();
if (clDg.ShowDialog() == DialogResult.OK)
{
clr = clDg.Color;
}
foreach (Control ctl in this.Controls)
{
if (ctl is MdiClient)
{
ctl.BackColor = clr;
}
}
}
private void Form1_MdiChildActivate(object sender, EventArgs e)
{
foreach (Form form in Application.OpenForms)
{
form.BackColor = clr;
}
}
Nilesh AvhadRank #3,587 · 406 reputationPosted Jan 20, 2013, 8:59 PM EST