We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Mouse Move Event on Every Mouse Click Event

Hi, Can any body tell me why am I getting a mouse move event with every mouse click event. I am having a simple form without any control on it. I have two handlers one for mouse move and one for mouse click. I am printing a Console.Writeline("Mouse Clicked") in mouse click handler and Console.Writeline("Mouse Moved") in mouse move handler. But whenever I click on the form follwoing lines are printed Mouse Clicked Mouse Moved Why is that? Please help me.

1 Reply

AD Administrator Syncfusion Team October 23, 2002 07:47 AM UTC

I don't know why Microsoft is firing a MouseMove after a click, whether its is by design or just a bug. But you can ignore it in your code by setting a flag in the click handler and testing it in the mousemove handler.
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
	If bIgnoreMouseMove Then
		bIgnoreMouseMove = False
		Return
	End If
	Console.WriteLine("Form1_MouseMove")
End Sub

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click

	Console.WriteLine("Form1_Click")
	bIgnoreMouseMove = True
End Sub

Loader.
Live Chat Icon For mobile
Up arrow icon