| Lets you click and drag from list box to list box. Assumes:Just add two list boxes to a form, and paste code. This code assumes list1 and list2 for names. Private Sub Form_Load() Dim Listcount1, Listcount2 As Integer Dim Itemstring1, Itemstring2 As String List1.OLEDragMode = 1 List2.OLEDragMode = 1 List1.OLEDropMode = 1 List2.OLEDropMode = 1 List2.AddItem "test seven" List1.AddItem "test" List1.AddItem "test one" List1.AddItem "test two" List1.AddItem "test three" List1.AddItem "test four" List1.AddItem "test five" List1.AddItem "test six" List1.AddItem "test seven" List1.AddItem "test eight" Listcount1 = List1.ListCount Listcount2 = List2.ListCount For X = 0 To Listcount1 Step 1 Itemstring1 = List1.List(X) For Y = 0 To Listcount2 Step 1 Itemstring2 = List2.List(Y) If Not Itemstring1 = "" Then If Itemstring1 = Itemstring2 Then List1.RemoveItem X Next Y Next X End Sub Private Sub List2_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) If Not List1.ListIndex = -1 Then List2.AddItem List1 List1.RemoveItem List1.ListIndex End If End Sub Private Sub List1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) If Not List2.ListIndex = -1 Then List1.AddItem List2 List2.RemoveItem List2.ListIndex End If End Sub Private Sub List1_MouseMove(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Button = 1 Then List1.OLEDrag End If End Sub Private Sub List2_MouseMove(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Button = 1 Then List2.OLEDrag End If End Sub |
Drag items from one list box to another |
Express News India | Freelance ecommerce web development India