Is there an event I can use to tell if a child form has been added or removed from the MDI parent?
I recently wanted to determine approximately when there were NO MDIchildren open so I could display a panel with lots of "things to do" buttons on it Only when there were no child forms open. (just exploring a design idea).
My eventual solution was elegantly simple - add a timer to the parent form and start the timer up whenever the MdiChildActivate event determined there was 1 child form open.
private void MyForm_MdiChildActivate(object sender, EventArgs e)
{
this.panel_Tools.Visible = false;
if (this.MdiChildren.Count() == 1)
{
this.timer_WindowsCounter.Start();
}
else
{
this.timer_WindowsCounter.Stop();
}
}
private void timer_WindowsCounter_Tick(object sender, EventArgs e)
{
if (this.MdiChildren.Count() == 0)
{
this.panel_Tools.Visible = true;
this.timer_WindowsCounter.Stop();
}
}