.NET Control - child controls (e.g. labels) do not listen to my mouseclick events

I have a user control that listens to certain onmousedown and onmouseover events.
The control also holds a few labels.

When I click on the control over those few labels, the onmousedown/over event listeners are not invoked.

So here comes my question: How to have a control including all its child to listen to all mouseclick events?
jtjliAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LordWabbitCommented:
When I click on the control over those few labels, the onmousedown/over event listeners are not invoked.

Sounds like the control you are trying to click on is actually behind your label and so the label is catching the mouse events and not the control behind it.  You might want to reposition your controls a bit or something.

Also to programatically add event handlers you would do something like this

Addhandler label1.MouseDown, Addressof MyMousdownHandler
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cubixSoftwareCommented:
Like LordWabbit suggests you can use the AddHandler, or simply define multiple Handles entries for your MouseDownProcedure... e.g.

Currently you may have

Private Sub usrControl_MouseDown(ByVal sender As Object, ByVal e As system.Windows.Forms.MouseEventArgs) Handles usrControl.MouseDown        

... code to do something

End Sub

But you could easily change to

Private Sub usrControl_MouseDown(ByVal sender As Object, ByVal e As system.Windows.Forms.MouseEventArgs) Handles usrControl.MouseDown, Label1.MouseDown, Label2.MouseDown, Label3.MouseDown          

... code to do something

End Sub


HTH

0
jtjliAuthor Commented:
>> Sounds like the control you are trying to click on is actually behind your label and so the label is catching the mouse events and not the control behind it

If my control is above my labels, then my labels will be hidden, right?  Or is there any workaround..
0
cubixSoftwareCommented:
>>If my control is above my labels, then my labels will be hidden, right?

Your user control is acting as a container to the labels. If you made the control higher in the Z-Order then you probably won't actually see the labels.

The behaviour you are experiencing can also be replicated by having a groupbox with a couple of labels within it.

The solution I proposed above is very straight forward so I am surprised you are still looking for another workaround, or is there some more issues we need to know about?
0
jtjliAuthor Commented:
i've accepted that there's no direct solution
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.