
30/09/2004, 01:48
|
| | Fecha de Ingreso: septiembre-2004
Mensajes: 29
Antigüedad: 20 años, 5 meses Puntos: 0 | |
Parte_3: (final)
Private Sub ListDragTarget_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles ListDragTarget.DragDrop
' Ensures that the list item index is contained in the data.
If (e.Data.GetDataPresent(GetType(System.String))) Then
Dim item As Object = CType(e.Data.GetData(GetType(System.String)), System.Object)
' Perform drag and drop, depending upon the effect.
If (e.Effect = DragDropEffects.Copy Or _
e.Effect = DragDropEffects.Move) Then
' Insert the item.
If (indexOfItemUnderMouseToDrop <> ListBox.NoMatches) Then
ListDragTarget.Items.Insert(indexOfItemUnderMouseT oDrop, item)
Else
ListDragTarget.Items.Add(item)
End If
End If
' Reset the label text.
DropLocationLabel.Text = "None"
End If
End Sub
Private Sub ListDragSource_QueryContinueDrag(ByVal sender As Object, ByVal e As QueryContinueDragEventArgs) Handles ListDragSource.QueryContinueDrag
' Cancel the drag if the mouse moves off the form.
Dim lb as ListBox = CType(sender, System.Windows.Forms.ListBox)
If Not (lb is nothing) Then
Dim f as Form = lb.FindForm()
' Cancel the drag if the mouse moves off the form. The screenOffset
' takes into account any desktop bands that may be at the top or left
' side of the screen.
If (((Control.MousePosition.X - screenOffset.X) < f.DesktopBounds.Left) Or _
((Control.MousePosition.X - screenOffset.X) > f.DesktopBounds.Right) Or _
((Control.MousePosition.Y - screenOffset.Y) < f.DesktopBounds.Top) Or _
((Control.MousePosition.Y - screenOffset.Y) > f.DesktopBounds.Bottom)) Then
e.Action = DragAction.Cancel
End If
End if
End Sub
Private Sub ListDragTarget_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) Handles ListDragTarget.DragEnter
' Reset the label text.
DropLocationLabel.Text = "None"
End Sub
Private Sub ListDragTarget_DragLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListDragTarget.DragLeave
' Reset the label text.
DropLocationLabel.Text = "None"
End Sub
End Class |