User Control MouseUp

  • Thread starter Thread starter Udi
  • Start date Start date
U

Udi

Hi,
I have a user control - A that has a panel that contains
a list of a different user control - B.
When I'm adding a new B to A, I'm subscribing a handler
(which is a method of A) to B.MouseUp.
However, when I click B the event is not fired.

See example:
class A : System.Windows.Forms.UserControl
{
void OnButtonAddBctrl(...)
{
:
B ctrl = new B(...); // B is a UserControl
ctrl.MouseUp +=new MouseEventHandler(Bctrl_MouseUp);
this.panel1.Controls.Add(ctrl);
:
}

void Bctrl_MouseUp(...)
{
// Never getting here when clicking B
}
}

What is wrong?
Thanks!
 
I think I know what my problem is -
the user control B is filled with a panel that contains a list of a
third user control - C.
So it seems like the panel "hides" the B from mouse events.
Do I need to pass (and subscribe) my handler to each and every one the
children of B( i.e the panel and all C's in it)?
Is there a way of doing it automatically?
Thanks.
 
Back
Top