Reputation: 2444
It appears that when I am using the MouseLeave
event to perform an action, if the user leaves the Control
fast enough, it will actually skip the MouseLeave
event..
The user will be out of the control
and the MouseLeave
event wasn't called. Now, I don't know if there is a way to fix this, or if there is a better event to use. I basically have a UserControl
that has a Combobox
in it. When the other scrolls over the UserControl
, the ComboBox
appears (works everytime), however, when they user leaves that Control
to go to another one, it may or may not make the ComboBox`.Visible = false. It seems to depend on the rate of the Cursor moving.
Any ideas guys?
Upvotes: 3
Views: 1157
Reputation: 24182
Sometime ago it happened to me! I had to hook mouse events using PInvoke, and do all the logic myself.
The following article contains details on how to hook mouse events.
http://www.codeproject.com/KB/cs/globalhook.aspx
After you manage to hook the events, you will need to do the logic of calculating the absolute position of your control, and tell whether mouse pointer is in or out. Then you need to keep track of the in/out changes, and it is all.
Long way to go... I would say this is an overkill. But if you really need it, anyway.
Upvotes: 1
Reputation: 612884
I'd imagine it happens when the mouse is captured: WM_MOUSELEAVE not being generated when left mouse button is held
Upvotes: 0
Reputation: 2154
Mouse leave event will call when you leave the control . I think you missed to registered it.
private void comboBox1_Leave(object sender, EventArgs e)
{
}
You can use comboboxleave event this will call when you leave this control and that is you are expecting i think :) Don't forget to register the event first
Upvotes: 0