title: C# Form UserControl OnClick events
body: <p>I've created a custom user control for a windows form that will operate similar to a button (and please don't suggest that I just use a button, because I will be storing data in this user control), but I can't figure out how to get the <code>OnClick()</code> event to fire. I've sifted through a handful of tutorials and looked at a few similar questions on the site, but I can't seem to get the event to fire off - so I'm either doing something wrong or everyone posted incorrect code (I hope it isn't the latter)</p>
  
  <p>In my custom control.cs, </p>
  
  <pre><code>namespace MobCreator {
      public partial class MOBSample : UserControl {
          public MOBSample() {
             InitializeComponent();
          }
          protected override void OnMouseUp(MouseEventArgs e) {
             this.BorderStyle = BorderStyle.FixedSingle;
             base.OnMouseUp(e);
          }
          protected override void OnMouseDown(MouseEventArgs e) {
             this.BorderStyle = BorderStyle.Fixed3D;
             base.OnMouseDown(e);
          }
          public event EventHandler ButtonClick;
          private void OnButtonClick(object sender, EventArgs e) {
             // invoke UserControl event here
             if (this.ButtonClick != null) this.OnButtonClick(sender, e);
          }
      }
  }
  </code></pre>
  
  <p>And in my form.cs, </p>
  
  <pre><code>private void MobCreatorForm_Load(object sender, EventArgs e) {
      UserControl1.ButtonClick += new EventHandler(this.CustomEvent_Handler);
  }
  private void CustomEvent_Handler(object sender, EventArgs e) {
      Console.WriteLine("Click");
  }
  </code></pre>
  
  <p>However, when I run the program my console never outputs "Click".</p>