Not sure if this is a bug or desired behavior. If it is desired not sure the reason. Real easy to duplicate, create a windows from project. Add a Listview, Treeview, and textbox. Then a mouse down and up events with a debug.print (“”) in each. Put a break
point on each of the debug.prints to see when the event is fired.
Here is what I am seeing, on the Listview and Treeview controls, the mouse up event fires immediately after the mouse down, even if the mouse key is still held down. To see it, just run the form, put the mouse over the Listview or Treeview, press and hold the
mouse button. When the break point stops, while hold the mouse down press the f5 and the mouse up fires. Then try the same thing on the textbox and form it behaves as expect. The mouse up does not fire until the button is released. Also if you press down on
the textbox or form, then release on the Listview or Treeview, it’s mouse up fires as expected. All thoughts are appreciated.
FYI, just for the curios, what I am trying to do is create a image picker, that the use can then sort the order of images picked. I have two listviews, one is the source and the other is the ones selected. Once images are drag and dropped from the source on
the destination listview, I wanted to allow the user to drag the image to control the order in the listview. I thought I could use flags to hold the x,y source item on the mouse down and x,y item on the mouse up, then rearrange the listview accordingly.
That’s when I discovered the behavior, then I created a virgin form and saw the same results. I could not find anything Googling.
I tried it on frame works 2,3,3.5, and 4. I got the same results on all of them. The one thing that was weird, is on version 2 frame work, when the break point hit the .net environment did not get focus. Once you gave it focus and pressed f5, then the mouse
up event fired like the others.
Here is the code you can past into the form and save some typing.
Public Class Form1
Private Sub Form1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Debug.Print("")
End Sub
Private Sub Form1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
Debug.Print("")
End Sub
Private Sub ListView1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDown
Debug.Print("")
End Sub
Private Sub ListView1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseUp
Debug.Print("")
End Sub
Private Sub TextBox1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseDown
Debug.Print("")
End Sub
Private Sub TextBox1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseUp
Debug.Print("")
End Sub
Private Sub TreeView1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown
Debug.Print("")
End Sub
Private Sub TreeView1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseUp
Debug.Print("")
End Sub
End Class