0

In my VB.Net forms application, I have a function:

Private Sub pnlMain_MouseLeave(sender As Object, e As System.EventArgs) Handles pnlMain.MouseLeave
...
End Sub

and another function:

Private Sub pnlMain_MouseEnter(sender As Object, e As System.EventArgs) Handles pnlMain.MouseEnter
...
End Sub

When the mouse enters or leaves both are executed - first Enter and then Leave. Why is this happening?

Chiwda
  • 1,233
  • 7
  • 30
  • 52

1 Answers1

1

It doesn't or it shouldn't

but if you have a breakpoint on the enter event then it will fire the mouseleave event as you hit it. (because you've triggered the leave event).

Johnno Nolan
  • 29,228
  • 19
  • 111
  • 160
  • You are right, I didn't think of that. However, it is happening even when not in debug mode. It executes the code in both events. – Chiwda Jun 19 '12 at 08:12
  • I've got a proof of concept that doesn't do that. – Johnno Nolan Jun 19 '12 at 08:24
  • @chiwda You need to be careful. Use logging to record when the events happen. Because otherwise the test reporting will trigger the leave event. E.g. If you bring up the debugger, show a message box... you will cause the Leave event – MarkJ Jun 19 '12 at 12:17