Forgive me if this is a stupid question, but I'm not experienced and didn't find an answer to this problem.
I'm putting labels on a Panel (Form8.Panel1) in code depending on data stored in a datatable (treedata):
For i = 0 To _tree.treedata.Rows.Count - 1
Dim tb As New Label
tb.Name = CStr(i)
tb.AutoSize = True
tb.MaximumSize = New Size(tb.Width, 70)
tb.MinimumSize = New Size(tb.Width, 0)
tb.Location = New Point(treedata.Rows(i)(11),treedata.Rows(i)(4))
AddHandler tb.MouseMove, AddressOf obj1_MouseMove
AddHandler tb.MouseDown, AddressOf obj1_MouseDown
Form8.Panel1.Controls.Add(tb)
Next
Using the MouseMove event I want to drag the labels around on the panel following the mouse:
Private Sub obj1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = MouseButtons.Left Then
sender.Location = New Point(Form8.MousePosition.X, Form8.MousePosition.Y)
End If
End Sub
What now happens is that when I click on a label and want it to follow the mouse it first "jumps away" meaning moves quite a bit away from the location of the mouse and only then follows the mouse. Does anyone know what I have to change in order to avoid this initial jump of the labels?