Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles DataGridView1.MouseDown
Dim cc As New customclass
cc.id = 1
cc.name = "the name"
DataGridView1.DoDragDrop(cc, DragDropEffects.Copy)
End Sub
Private Sub ListBox1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) _
Handles ListBox1.DragOver
If e.Data.GetDataPresent(GetType(customclass)) = True Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) _
Handles ListBox1.DragDrop
If e.Data.GetDataPresent(GetType(customclass)) = True Then
ListBox1.Items.Add(DirectCast(e.Data.GetData(GetType(customclass)), customclass))
End If
End Sub
Public Class customclass
Public name As String
Public id As Integer
Public Overrides Function ToString() As String
Return id.ToString & ". " & name
End Function
End Class