1
votes

I am working on a Windows Forms MDI application which can create new child forms within itself. The parent form has a StatusLabel in a Statusstrip. I am trying to figure out how to change the StatusLabel text value of the parent form to the name of an active child form. I have created a "activated" event in the child form but I don't know how to change the parents form statusLabel from the child's forms "activated" code block.

Basically I want to change a label in the parent form to to the child forms name property.

Any help would be greatly appreciated.

1

1 Answers

0
votes

Try subscribing to the Activated event of the child form:

protected override void OnLoad(EventArgs e) {
  base.OnLoad(e);

  for (int i = 0; i < 3; ++i) {
    Form f = new Form();
    f.Activated += f_Activated;
    f.MdiParent = this;
    f.Text = "Form #" + i.ToString();
    f.Show();
  }      
}

void f_Activated(object sender, EventArgs e) {
  toolStripStatusLabel1.Text = ((Form)sender).Text;
}