Hi All,

I want to learn more about drag and drop.
I've got this code, who's working very well, to drag and drop a Label over a form and with checking borders.


VB Code:
  1. Private Sub Label1_MouseMove(ByVal sender As Object, _
  2.             ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove
  3.         Static mousePosX As Single, mousePosY As Single
  4.         Dim currentx As Single, currenty As Single
  5.  
  6.         If e.Button = 0 Then
  7.             mousePosX = e.X
  8.             mousePosY = e.Y
  9.         Else
  10.             currentx = Label1.Left + (e.X - mousePosX)
  11.             currenty = Label1.Top + (e.Y - mousePosY)
  12.             If Not (currentx < 0 Or currentx + Label1.Width > Me.Width) Then
  13.                 Label1.Left = currentx
  14.             End If
  15.  
  16.             If Not (currenty < 0 Or currenty + Label1.Height > Me.ClientSize.Height) Then
  17.                 Label1.Top = currenty
  18.             End If
  19.         End If
  20.     End Sub

The problem I'm having is, what do I have to do that if I'm using several labels the Labelsborders will be checked (doesn't run over each other) and
the labels can be drag and dropped seperatly.

Thanks in advance,

sparrow1