The below code is working great for selecting an item from one listbox and dragging over to another listbox. I'm trying to figure out how to drag all the selected items over. This code will only let me drag one selected item over. Both listboxes are set to multiselect.
Any help would be appreciated
Thanks
Private Sub List1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles List1.DragDrop
Try
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim strElementDestiny As String =
e.Data.GetData(DataFormats.StringFormat).ToString()
List1.Items.Add(strElementDestiny)
End If
Catch ex As Exception
MsgBox("Please Click a Container Number to Continue !")
End Try
End Sub
Private Sub List1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles List1.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub List1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles List1.MouseDown
Try
If (List1.Items.Count > 0) Then
Dim index As Integer = List1.IndexFromPoint(e.X, e.Y)
Dim strElementOrigin As String = List1.Items(index).ToString()
Dim dde As DragDropEffects = DoDragDrop(strElementOrigin,
DragDropEffects.All)
If dde = DragDropEffects.All Then
List1.Items.RemoveAt(List1.IndexFromPoint(e.X, e.Y))
End If
End If
l14.Text = List2.Items.Count
Catch ex As Exception
MsgBox("Please Click a Container Number to Continue !")
End Try
End Sub
Private Sub List2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles List2.DragDrop
Try
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim strElementDestiny As String =
e.Data.GetData(DataFormats.StringFormat).ToString()
List2.Items.Add(strElementDestiny)
End If
Catch ex As Exception
MsgBox("Please Click a Container Number to Continue !")
End Try
End Sub
Any help would be appreciated
Thanks
Private Sub List1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles List1.DragDrop
Try
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim strElementDestiny As String =
e.Data.GetData(DataFormats.StringFormat).ToString()
List1.Items.Add(strElementDestiny)
End If
Catch ex As Exception
MsgBox("Please Click a Container Number to Continue !")
End Try
End Sub
Private Sub List1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles List1.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub List1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles List1.MouseDown
Try
If (List1.Items.Count > 0) Then
Dim index As Integer = List1.IndexFromPoint(e.X, e.Y)
Dim strElementOrigin As String = List1.Items(index).ToString()
Dim dde As DragDropEffects = DoDragDrop(strElementOrigin,
DragDropEffects.All)
If dde = DragDropEffects.All Then
List1.Items.RemoveAt(List1.IndexFromPoint(e.X, e.Y))
End If
End If
l14.Text = List2.Items.Count
Catch ex As Exception
MsgBox("Please Click a Container Number to Continue !")
End Try
End Sub
Private Sub List2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles List2.DragDrop
Try
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim strElementDestiny As String =
e.Data.GetData(DataFormats.StringFormat).ToString()
List2.Items.Add(strElementDestiny)
End If
Catch ex As Exception
MsgBox("Please Click a Container Number to Continue !")
End Try
End Sub