0

Context:

Form / TableLayoutPanel / UserControl

Example handler in the user control:

protected override void OnMouseDown(MouseEventArgs e)
{
    base.OnMouseDown(e);
}

I want to notify the Form that the UserControl intercepted the OnMouseDown event and the form needs to know what Point the user had clicked.

How can I acheive this? Thanks!

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • Found this: http://stackoverflow.com/questions/2024506/how-to-pass-messages-from-a-child-user-control-to-the-parent – Andrew Truckle Jun 03 '16 at 18:56
  • 2
    Why don't you subscribe for mouse events of `UserControl` in `Form`? – Reza Aghaei Jun 03 '16 at 19:24
  • @RezaAghaei How do you do that? I ended up using custom event handlers and actions. What you suggest sounds simpler. – Andrew Truckle Jun 04 '16 at 05:40
  • 1
    @AndrewTruckle Custom Event Handlers or Actions are OK too. But since your `UserControl` has a `MouseDown` event, you can handle that event in your form ad put your custom logic there. Handling that event is as simple as handling `Click` event of `Button` or other events like `Load` of `Form`. – Reza Aghaei Jun 04 '16 at 20:05

0 Answers0