PDA

Click to See Complete Forum and Search --> : Drag & Drop Multiple List Entries


Tupalov
Nov 22nd, 1999, 10:28 PM
When a listbox's Multiselect property is set to Extended how do you drag multiple items? If you start moving with the mouse button down, you just select more entries.

Aaron Young
Nov 23rd, 1999, 11:08 AM
Try this example I put together using 2 Listboxes.. (Make sure the DragMode is Manual)..

Private Sub Form_Load()
Dim iIndex As Integer
For iIndex = 1 To 10
List1.AddItem "Item " & iIndex
Next
End Sub

Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then List1.Drag vbBeginDrag
End Sub

Private Sub List1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
List1.Drag vbEndDrag
End Sub

Private Sub List2_DragDrop(Source As Control, X As Single, Y As Single)
Dim iIndex As Integer
If TypeOf Source Is ListBox Then
List2.Clear
For iIndex = 0 To Source.ListCount - 1
If Source.Selected(iIndex) Then List2.AddItem Source.List(iIndex)
Next
End If
End Sub



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

Tupalov
Nov 23rd, 1999, 11:22 AM
I was trying to duplicate the functionality of explorer, where you could select a bunch of items from a list, let go of the mouse, then mousedown on one of the selected items and they would all be dragged.

Thanks.

Chris