I develop a WinForms UserControl in C#.
The UserControl is essentially a composite control that consists of several child controls, e.g. a PictureBox, a CheckBox, a Label, etc.
From the calling code, I want to be able handling a Click event for my control.
However, I want the event raised if and only if the user clicks on a certain component of my control, e.g. the PictureBox. If the user clicks anywhere else within my control, the event should not be raised.
How can I do that?
Assuming you are using WinForms.
You should delegate a
Clickevent from a pictureBox into your own event and then subscribe to it from the calling code.