User Control MouseUp

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!
 
U

Udi

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top