How to drag/drop labels ,that created at run time

this is my code ...

Private Sub server1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles server1.Click
       
        'create new form 
        Dim ser1 As New Form
       
        Dim l1 As New Label()
       
        ser1.Location = New Point(123, 28)
        ser1.Height = 95
        ser1.Width = 206
      

            l1.AllowDrop = True
           
            l1.Name = "Lab1"
           
            l1.Text = "label1"
            l1.Location = New Point(5, 5 )
            ser1.Controls.Add(l1)

            ser1.Show()

        l1.DoDragDrop(l1, DragDropEffects.Move)
    End Sub

 Private Sub picturebox3_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles server3.DragEnter
        If (e.Data.GetDataPresent(DataFormats.Text)) Then
            ' Display the copy cursor.
            e.Effect = DragDropEffects.Copy
        Else
            ' Display the no-drop cursor.
            e.Effect = DragDropEffects.None
        End If

    End Sub

Recommended Answers

All 3 Replies

I know this way
but how I can implement mouse clicking and moving to labels created at run time ???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.