Alright my goal is to test to see if the user has dragged a label over a button. I have add event handlers for MouseMove and ButtonEnter, the trick is that i dont want the buttonEnter sub to fire unless the user is actually dragging a label.
vb Code:
Dim dragging As Boolean = False Public Sub Label_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Static lOffset As Point lbl = DirectCast(sender, Label) If e.Button = MouseButtons.None Then lOffset = New Point(e.Location) dragging = False ElseIf e.Button = MouseButtons.Left Then lbl.Location = lbl.Location + e.Location - lOffset dragging = True End If End Sub Private Sub Button_MouseEnter(sender As System.Object, e As System.EventArgs) If dragging = True Then MsgBox("This is a Test") End If End Sub
I thought would work but because the user is dragging the label the mouse never actually enters the button field.
I also tried doing lbl.location = button.location... but unless the label and the buttons are the exactly the same size in exactly the same location then the event wont trigger.
Is there an easy solution to this?




Reply With Quote