We help IT Professionals succeed at work.
Get Started

Get Mouse Enter event and mouse leave event to fire C# Winforms

gsdevEE
gsdevEE asked
on
4,430 Views
Last Modified: 2013-12-17
I have a combobox dropdownlist (A 3rd party control that allows you to get the height of the dropdown area) as well as a 3rd Party ToolTip control (this is needed instead of windows as it allows for the tip to show combobox list items as the are hovered over).

The issue I am having involves that when you hover over an item and quickly move the mouse away, the tooltip for the last item pops up.

I need to be able to determine if the mouse cursor is still inside the dropdoiwn area, and if it isnt cancel the tooltip pop-up event.

I tried doing this a few ways, first by getting a panel, setting the location, width and hieght to that of the dropdown area, and then attaching mouse enter and leave events, setting a bool on enter and on leave to determine if the mouse was still in the area, yet they do not fire as expected - then I read that the mouse enter and leave isnt exactly what I am looking for - I found this comment on the web suggesting another idea...

"You could iterate through the control tree and add MouseEnter and
MouseLeave events to every single control. Then do the same for every
single ControlAdded and ControlRemoved, adding/removing all four event
bindings to every new control added anywhere in the tree. Just recurse
through the control.Controls collection."

I dont know if this is the way to go, but at this point I am willing to try anything that works - does anyone know how to accomplish this or another way to determine if the mouse cursor has entered/left a control area such as a panel ??
Comment
Watch Question
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE