Updated: October 2008
Specifies the possible effects of a drag-and-drop operation.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
|The drop target does not accept the data.|
|The data from the drag source is copied to the drop target.|
|The data from the drag source is moved to the drop target.|
|The data from the drag source is linked to the drop target.|
|The target can be scrolled while dragging to locate a drop position that is not currently visible in the target.|
|The combination of the Copy, , and effects.|
You can use to display different mouse pointers for drag-and-drop operations. For example, you can display a plus symbol for a drag-and-drop operation, an arrow symbol for a drag-and-drop operation, or a red circle with a line through it symbol for a drag-and-drop operation.
If you want to drop data at a position in the target that is not currently visible, you could scroll the target while dragging. If a target does not support scrolling, you must make sure that the drop position is visible in the target before you begin the drag-and-drop operation. The following are some scenarios when you might want to scroll a target:
You are dragging text into a document, and you want to drop the text at a position not visible in the document window.
You are dragging a file into a file tree, and you want to drop the file on a node not visible in the file tree.
This code example demonstrates using the enumeration when the user moves the mouse over the drop target during a drag-and-drop operation. This code example is part of a larger example provided for the DoDragDrop method of the Control class. See the DoDragDrop method for the complete code example.
Private Sub ListDragTarget_DragOver(ByVal sender As Object, ByVal e As DragEventArgs) Handles ListDragTarget.DragOver ' Determine whether string data exists in the drop data. If not, then ' the drop effect reflects that the drop cannot occur. If Not (e.Data.GetDataPresent(GetType(System.String))) Then e.Effect = DragDropEffects.None DropLocationLabel.Text = "None - no string data." Return End If ' Set the effect based upon the KeyState. If ((e.KeyState And (8 + 32)) = (8 + 32) And _ (e.AllowedEffect And DragDropEffects.Link) = DragDropEffects.Link) Then ' KeyState 8 + 32 = CTL + ALT ' Link drag-and-drop effect. e.Effect = DragDropEffects.Link ElseIf ((e.KeyState And 32) = 32 And _ (e.AllowedEffect And DragDropEffects.Link) = DragDropEffects.Link) Then ' ALT KeyState for link. e.Effect = DragDropEffects.Link ElseIf ((e.KeyState And 4) = 4 And _ (e.AllowedEffect And DragDropEffects.Move) = DragDropEffects.Move) Then ' SHIFT KeyState for move. e.Effect = DragDropEffects.Move ElseIf ((e.KeyState And 8) = 8 And _ (e.AllowedEffect And DragDropEffects.Copy) = DragDropEffects.Copy) Then ' CTL KeyState for copy. e.Effect = DragDropEffects.Copy ElseIf ((e.AllowedEffect And DragDropEffects.Move) = DragDropEffects.Move) Then ' By default, the drop action should be move, if allowed. e.Effect = DragDropEffects.Move Else e.Effect = DragDropEffects.None End If ' Gets the index of the item the mouse is below. ' The mouse locations are relative to the screen, so they must be ' converted to client coordinates. indexOfItemUnderMouseToDrop = _ ListDragTarget.IndexFromPoint(ListDragTarget.PointToClient(New Point(e.X, e.Y))) ' Updates the label text. If (indexOfItemUnderMouseToDrop <> ListBox.NoMatches) Then DropLocationLabel.Text = "Drops before item #" & (indexOfItemUnderMouseToDrop + 1) Else DropLocationLabel.Text = "Drops at the end." End If End Sub
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.