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?
Sudhakar ChaudharyPosted Jan 17, 2013, 1:09 AM
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 AvhadPosted Jan 21, 2013, 1:59 AM