[VB.NET] Drag & Drop multiselection on listview
-
I'm trying to use drag & drop with a multiselection. I would like to copy the listview selected items on an other listview. I tried that :
Private Sub lstAllRole_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstAllRole.MouseDown lstAllRole.DoDragDrop(lstAllRole.SelectedItems, DragDropEffects.Copy) End Sub Private Sub lstRole_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lstRole.DragEnter ' If e.Data().GetDataPresent("System.Windows.Forms.ListView.ListViewItemCollection", False) Then If e.Data().GetDataPresent(lstAllRole.SelectedItems.GetType().ToString(), False) Then e.Effect() = DragDropEffects.Copy Else e.Effect() = DragDropEffects.None End If End Sub Private Sub lstRole_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lstRole.DragDrop Dim obj As ListViewItem Dim objCol As Object For Each obj In e.Data.GetData(lstAllRole.SelectedItems.GetType().ToString(), False) lstRole.Items.Add(obj) Next End Sub
The drag & drop works but not the copy. Does someone already do it ? Thanks