Would it be possible to drag one value from a (a)list box into another (b)list box?
And if so if I dragged more than one value into the (b)list box would it add then next value or overwright the first value?
Printable View
Would it be possible to drag one value from a (a)list box into another (b)list box?
And if so if I dragged more than one value into the (b)list box would it add then next value or overwright the first value?
Yes it is possible.
I will reply again with code.
You have to set the OLEDragMode to 1-Automatic for lista and the dropmode to 1-manual for listb.Code:Private Sub Form_Load()
With Lista
.AddItem "1"
.AddItem "2"
.AddItem "3"
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "7"
.AddItem "8"
.AddItem "9"
End With
End Sub
Private Sub Lista_OLESetData(Data As DataObject, DataFormat As Integer)
Data.SetData Lista.List(Lista.ListIndex)
End Sub
Private Sub Listb_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
With Listb
.AddItem Data.GetData(1)
End With
End Sub
You could also do this:
Code:'Code from Megatron
Dim StartDrag As Boolean
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
StartDrag = True
strTemp = List1.Text
End Sub
Private Sub List2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If StartDrag = True Then
List2.AddItem List1.Text
List1.RemoveItem List1.ListIndex
End If
StartDrag = False
End Sub