Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi Select Drag and Drop Using Listbox

Status
Not open for further replies.

dvannoy

MIS
May 4, 2001
2,765
0
0
US
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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top