title: Binding click events of all UserControl's controls to single event on parent Control
body: <p>I am trying to implement an event handler for my user control that triggers a click whenever any control inside the user control or the user control itself is clicked.</p>
  
  <pre><code>public event EventHandler ClickCard
  {
      add
      {
          base.Click += value;
          foreach (Control control in GetAll(this, typeof(Control)))
          {
              control.Click += value;
          }
      }
      remove
      {
          base.Click -= value;
          foreach (Control control in GetAll(this, typeof(Control)))
          {
              control.Click -= value;
          }
      }
  }
  public IEnumerable&lt;Control&gt; GetAll(Control control, Type type)
  {
      var controls = control.Controls.Cast&lt;Control&gt;();
  
      return controls.SelectMany(ctrl =&gt; GetAll(ctrl, type))
                                        .Concat(controls)
                                        .Where(c =&gt; c.GetType() == type);
  }
  </code></pre>
  
  <p>I modified the code given <a href="https://stackoverflow.com/questions/5820490/click-event-for-net-windows-forms-user-control">here</a> to bind all the nested controls. This is how I am binding the event on which this user control is used:</p>
  
  <pre><code>private void feedbackCard1_ClickCard_1(object sender, EventArgs e)
  {
      MessageBox.Show("Thank You!");
  }
  </code></pre>
  
  <p>But the click is not firing on clicking any of the controls inside the user control or the user control itself.</p>