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:
Private Sub Label1_MouseMove(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove Static mousePosX As Single, mousePosY As Single Dim currentx As Single, currenty As Single If e.Button = 0 Then mousePosX = e.X mousePosY = e.Y Else currentx = Label1.Left + (e.X - mousePosX) currenty = Label1.Top + (e.Y - mousePosY) If Not (currentx < 0 Or currentx + Label1.Width > Me.Width) Then Label1.Left = currentx End If If Not (currenty < 0 Or currenty + Label1.Height > Me.ClientSize.Height) Then Label1.Top = currenty End If End If 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





Reply With Quote