Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Add two List View controls to a form. Set the AllowDrop property of each List View control to true. Set the MultiSelect property of each List View control to true. Set the View property of each List View control to List. Add the following code:</p> <p>Public Class Form1</p> <pre><code>Private Sub ListView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragDrop, ListView2.DragDrop Dim myItem As ListViewItem Dim myItems() As ListViewItem = e.Data.GetData("System.Windows.Forms.ListViewItem()") Dim i As Integer = 0 For Each myItem In myItems ' Add the item to the target list. sender.Items.Add(myItems(i).Text) ' Remove the item from the source list. If sender Is ListView1 Then ListView2.Items.Remove(ListView2.SelectedItems.Item(0)) Else ListView1.Items.Remove(ListView1.SelectedItems.Item(0)) End If i = i + 1 Next End Sub Private Sub ListView1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragEnter, ListView2.DragEnter ' Check for the custom DataFormat ListViewItem array. If e.Data.GetDataPresent("System.Windows.Forms.ListViewItem()") Then e.Effect = DragDropEffects.Move Else e.Effect = DragDropEffects.None End If End Sub Private Sub ListView1_ItemDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles ListView2.ItemDrag, ListView1.ItemDrag Dim myItem As ListViewItem Dim myItems(sender.SelectedItems.Count - 1) As ListViewItem Dim i As Integer = 0 ' Loop though the SelectedItems collection for the source. For Each myItem In sender.SelectedItems ' Add the ListViewItem to the array of ListViewItems. myItems(i) = myItem i = i + 1 Next ' Create a DataObject containg the array of ListViewItems. sender.DoDragDrop(New _ DataObject("System.Windows.Forms.ListViewItem()", myItems), _ DragDropEffects.Move) End Sub </code></pre> <p>End Class</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload