Tag Archives: Label control

Drag and drop operation between Labels in vb.net

 
This example shows drag and drop operation between Labels in vb.net.

    Private Sub Label1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
        If e.Button = MouseButtons.Left Then
            Label1.DoDragDrop(Label1.Text, DragDropEffects.Copy Or DragDropEffects.Move)
        End If
    End Sub
 
    Private Sub Label2_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Label2.DragEnter
        e.Effect = DragDropEffects.Copy
    End Sub
 
    Private Sub Label2_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Label2.DragDrop
        Label2.Text = e.Data.GetData(DataFormats.Text).ToString
    End Sub