title: How do i create an event in a mdi parent form and catch it in a child form
body: <p>I've found a fair amount of information on this subject and stolen most of my current code from other threads on this forum but don't seem to be able to put it all together correctly.  I've created a main form "Form1" that is a mdi container.  I can create a child form "formStripChart" from a menu item on Form1.  I'd like to fire my own event that gets fired every time a timer_tick handler fires in Form1 and catch my event in an event hander in formStripChart to update a chart control.  I can see that Form1 is calling the "UpdateStatus" method but OnUpdateStatus is always null so the "UpdateStatus" event handler in formStripChart never gets called.  Seems like I'm not doing whatever needs to be done in formStripChart to make Form1 realize someone is listening to the event but I haven't been able to figure out what.  </p>
  
  <p>Here's the relevant code in Form 1</p>
  
  <pre><code>   public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          public delegate void StatusUpdateHandler(object sender, ProgressEventArgs e);
          public event StatusUpdateHandler OnUpdateStatus;
  
          private static double depthValue = 0.0;
          private static Random randomValue = new Random();
  
          private void timerData_Tick(object sender, EventArgs e)
          {
              depthValue = depthValue + randomValue.NextDouble() - 0.5;   
  
              iusblEventArgs.xValue = 0.0;
              iusblEventArgs.yValue = 0.0;
              iusblEventArgs.zValue = depthValue;
              iusblEventArgs.timeStamp = DateTime.Now;
  
              ProgressEventArgs args = new ProgressEventArgs("test status");
              UpdateStatus("sent from timerData_tick");
          }
  
          private void UpdateStatus(string status)
          {
              // Make sure someone is listening to event
              if (OnUpdateStatus == null) return;
  
              ProgressEventArgs args = new ProgressEventArgs(status);
              OnUpdateStatus(this, args);
          }
  
          public class ProgressEventArgs : EventArgs
          {
              public string Status { get; private set; }
  
              public ProgressEventArgs(string status)
              {
                  Status = status;
              }
          }
          private void btnGo_Click(object sender, EventArgs e)
          {
              timerData.Enabled = true;
          }
  </code></pre>
  
  <p>and here's the relevant code in formStripChart</p>
  
  <pre><code>    public partial class FormStripChart : Form
  {
      private Form1 form1;
      public FormStripChart()
      {
          InitializeComponent();
          form1 = new Form1();
          form1.OnUpdateStatus += new Form1.StatusUpdateHandler(UpdateStatus);
      }
  
      private void UpdateStatus(object sender, Form1.ProgressEventArgs e)
      {
          Console.Write("Update the chart here");
      }
  }
  </code></pre>
  
  <p>Thanks for any help.</p>