If the drag moves over a ListBox, the DragOver event gives the control a chance to allow or prohibit the drag. The following code checks whether the drag can provide a string as data. If so, then it checks whether the Ctrl key is down and allows a move or copy effect.
' Display the appropriate cursor.
Private Sub lstFruits_DragOver(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DragEventArgs) Handles _
lstFruits.DragOver, lstAnimals.DragOver
Const KEY_CTRL As Integer = 8
If Not (e.Data.GetDataPresent(GetType(System.String))) _
Then
e.Effect = DragDropEffects.None
ElseIf (e.KeyState And KEY_CTRL) And _
(e.AllowedEffect And DragDropEffects.Copy) = _
DragDropEffects.Copy Then
' Copy.
e.Effect = DragDropEffects.Copy
ElseIf (e.AllowedEffect And DragDropEffects.Move) = _
DragDropEffects.Move Then
' Move.
e.Effect = DragDropEffects.Move
End If
End Sub
Dizeleri Bir Listbox'tan Diğerine Sürükleyip Bırakın
Konuyu Okuyanlar: 1 Ziyaretçi