OK, I have drag-drop working between one listbox and another (and back) with
the code below.
But I can't get it to work when I change the selection mode to multi or
multi extended.
Any help would be much appreciated.
Bernie
Private Sub frombox3_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles frombox3.MouseDown
Dim Pt As New Point(e.X, e.Y)
Dim Index As Integer
frombox3 = sender
Index = frombox3.IndexFromPoint(Pt)
If Index >= 0 Then
frombox3.DoDragDrop(frombox3.Items(Index), DragDropEffects.Move)
End If
End Sub
Private Sub tobox3_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles tobox3.MouseDown
Dim Pt As New Point(e.X, e.Y)
Dim Index As Integer
tobox3 = sender
Index = tobox3.IndexFromPoint(Pt)
If Index >= 0 Then
tobox3.DoDragDrop(tobox3.Items(Index), DragDropEffects.Move)
End If
End Sub
Private Sub frombox3_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles frombox3.DragDrop
frombox3.Items.Add(e.Data.GetData(DataFormats.Text ).ToString)
tobox3.Items.Remove(e.Data.GetData(DataFormats.Tex t).ToString)
End Sub
Private Sub tobox3_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles tobox3.DragDrop
tobox3.Items.Add(e.Data.GetData(DataFormats.Text). ToString)
frombox3.Items.Remove(e.Data.GetData(DataFormats.T ext).ToString)
End Sub
Private Sub tobox3_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles tobox3.DragEnter
Dim x As Integer
x = tobox3.FindStringExact(e.Data.GetData(DataFormats. Text).ToString, -1)
If x <> -1 Then
Exit Sub
End If
If (e.Data.GetDataPresent(DataFormats.Text)) Then
e.Effect = DragDropEffects.Move
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub frombox3_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles frombox3.DragEnter
Dim x As Integer
x = frombox3.FindStringExact(e.Data.GetData(DataFormat s.Text).ToString, -1)
If x <> -1 Then
Exit Sub
End If
If (e.Data.GetDataPresent(DataFormats.Text)) Then
e.Effect = DragDropEffects.Move
Else
e.Effect = DragDropEffects.None
End If
End Sub