Skip to main content
A newer version of this page is available. .

DragDropEvents.DragOver Event

Occurs when a data element is dragged over the control’s bounds.

Namespace: DevExpress.Utils.DragDrop

Assembly: DevExpress.Utils.v19.2.dll

Declaration

[DXCategory("DragDrop")]
public event DragOverEventHandler DragOver

Event Data

The DragOver event's data class is DragOverEventArgs. The following properties provide information specific to this event:

Property Description
Action Gets or sets the drag-and-drop action (Copy, Move, etc.) to perform. Inherited from DXDragEventArgs.
Cursor Gets or sets the mouse pointer. Inherited from DXDragEventArgs.
Data Gets or sets the data elements being dragged. Inherited from DXDragEventArgs.
Handled Gets or sets whether the event was handled and allows you to suppress the default action. Inherited from DXDefaultEventArgs.
InsertIndicator Gets or sets an image that represents the insert indicator.
InsertIndicatorLocation Gets or sets the location of the defalt insert indicator.
InsertIndicatorSize Gets or sets the size of the default insert indicator.
InsertType Gets or sets whether dragged data elements are inserted before or after a data element under the mouse pointer, or as a child (for tree list only). Inherited from DragOverEventArgsBase.
KeyState Gets the pressed mouse buttons (left, middle, right) and modifier keys (Shift, Ctrl, Alt). Inherited from DXDragEventArgs.
Location Gets the mouse cursor’s position. Inherited from DXDragEventArgs.
Source Gets the source control. Inherited from DXDragEventArgs.
Tag Gets or sets custom data associated with the drag-and-drop operation. Inherited from DragOverEventArgsBase.
Target Gets the target control. Inherited from DXDragEventArgs.

The event data class exposes the following methods:

Method Description
Default() Invokes the default action the attached control performs on the current drag-and-drop operation stage. Inherited from DXDefaultEventArgs.
GetData<T>() Returns the data elements being dragged. Inherited from DXDragEventArgs.

Example

The example below shows how to cancel an operation if Ctrl is not pressed.

using DevExpress.Utils.DragDrop;

//The operation is only allowed when Ctrl is pressed.
private void dragDropEvents1_DragOver(object sender, DragOverEventArgs e) {
    e.Default();
    if (e.KeyState.HasFlag(DragDropKeyState.Control)) {
        e.Cursor = Cursors.Arrow;
        e.Action = DevExpress.Utils.DragDrop.DragDropActions.Copy;
    } else {
        e.Cursor = Cursors.No;
        e.Action = DragDropActions.None;
    }
}

Note

When you handle the DragOver event for a grid view, use the static (Shared in VB) DragOverGridEventArgs.GetDragOverGridEventArgs method to calculate arguments specific to the grid view.

using DevExpress.Utils.DragDrop;
using DevExpress.XtraGrid.Views.Grid;

dragDropEvents1.DragOver += Behavior_DragOver;

private void Behavior_DragOver(object sender, DragOverEventArgs e) {
   DragOverGridEventArgs args = DragOverGridEventArgs.GetDragOverGridEventArgs(e);
   //You can also cast DragOverEventArgs to DragOverGridEventArgs.
   //DragOverGridEventArgs args = (DragOverGridEventArgs)e;
}

Note

Run the XtraTreeList or XtraGrid demo and click Open Solution for more examples.

See Also