Is there a way to fire the child controls event on the parent control?
Sample: a custom user control called ControlA containing other controls, like a PictureBox and a Label. The ControlA is added to a Form and a MouseClick event is set. If the user clicks on the empty areas of the control, the event is fired, but if the user clicks over the child controls, like the PictureBox and the Label, nothing happens. This is because the child controls are over the Background and will handle the events.
The solution that I found is to add that:
public new event MouseEventHandler MouseClick
{
add
{
base.MouseClick += value;
foreach (Control control in Controls)
{
control.MouseClick += value;
}
}
remove
{
base.MouseClick -= value;
foreach (Control control in Controls)
{
control.MouseClick -= value;
}
}
}
But I will need to do that to all Events that I want to use, is there some another way to solve that, like setting some property on the child controls, so I don't need to "override" a lot of events?