Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a special customized Control which includes another Control in it - in this case a Textbox. The Control itself works like it should ... but not some of the MouseEvents. I like to have not a MouseHover for the Parent-Control and one for the included Control - I like to have the MouseHover only for the Parent , also when the Mouse hovers over the included (Child-) Control. The same for MouseEnter, MouseLeave and MouseMove.
The Prent isn't a real Container - it derives from Control ...

What I have tried:

I tried to catch the Events from (for example) MouseEnter from both Controls (Parent and Child). But this doesn't work well because if I enter the Area of the Child I also leave the Area of the Parent. The final Event should only be raised when entering the Parent. The same for MouseLeave - this Event should only be raised when leaving the Parent but not when entering the Child ...

I tried this but i doesn't work like it should ...
VB
Private Sub Me_MouseLeave(sender As Object, e As EventArgs) Handles Me.MouseLeave, innerTextbox.MouseLeave
    Dim p As Point = Me.PointToClient(MousePosition)
    If Not Me.ClientRectangle.Contains(MousePosition) Then Me.OnMouseLeave(e) : isEntered = False
End Sub
Posted
Updated 29-Dec-20 21:54pm

1 solution

 
Share this answer
 
v2
Comments
Ralf Meier 30-Dec-20 4:16am    
Hi Rick,
thanks for your Solution - it answers one part of my question ... but sorry ... not the one for MouseEnter / MouseLeave.
The difference is that MouseHover, MouseClick and so on could be hooked and directed to another method which makes a common Event.
The 2 Events from above neutralize each other ... this is the point where I stuck ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900