I want to make a Label that I can drag and drop. At the same time when I drag the original label it will leave a copy of it self.
Example: When I drag Label1 it will leave another Label to its Original Position( Lets Name the New Label1 in Original Position as Label2),
Then I should also be able to drag Label2 and Leave another Label (Label3), I also want to drag Label1 and Label2 but it should not leave a copy.
Here is my code: I been able to do multiplication of Label and Dragging of Label but I cannot drag all Labels:
Public Class Form1 Dim cursorX, cursorY As Integer Dim dragging As Boolean Dim labelno As Integer = 1 Private Sub Control_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown dragging = True cursorX = e.X cursorY = e.Y Dim label2 As New Label labelno += 1 label2.Location = New Point(Label1.Location.X, Label1.Location.Y) label2.Name = "Label" + labelno.ToString label2.Text = label2.Location.ToString Me.Controls.Add(label2) End Sub Private Sub Control_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseUp dragging = False End Sub Private Sub control_MouseMOve(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove If dragging Then Dim ctrl As Control = CType(sender, Control) ctrl.Left = (ctrl.Left + e.X) - cursorX ctrl.Top = (ctrl.Top + e.Y) - cursorY ctrl.BringToFront() End If End Sub
If you have clarification please inform me.
Thanks