DragDropBehaviorBase<TDragDropBehaviorSource, TDragDropBehaviorProperties>.DragEnter Event
Occurs when a data element is dragged into the control’s bounds.
Namespace: DevExpress.Utils.DragDrop
Assembly: DevExpress.Utils.v24.1.dll
NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core
Declaration
Event Data
The DragEnter event's data class is DragEnterEventArgs. 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. |
AllowDrop | Gets or sets whether it is allowed to drop data elements to the target control. |
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. |
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. |
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. |
Remarks
If you attached the Drag-and-Drop Behavior to a control in the designer, use the DragDropEvents component to subscribe to the drag-and-drop events.
Example
This example shows how to prohibit to drop specific data.
private void dragDropEvents1_DragEnter(object sender, DragEnterEventArgs e) {
List<TreeListNode> list = e.Data as List<TreeListNode>;
// You can prohibit to drop specific data.
if (list.Find((x) => x.GetValue(colDEPARTMENT1).ToString().Contains("Finance")) != null) {
e.AllowDrop = false;
e.Cursor = Cursors.No;
e.Handled = true;
}
}
private void dragDropEvents1_DragOver(object sender, DevExpress.Utils.DragDrop.DragOverEventArgs e) {
List<TreeListNode> list = e.Data as List<TreeListNode>;
// You can prohibit to drop specific data.
if (list.Find((x) => x.GetValue(colDEPARTMENT1).ToString().Contains("Finance")) != null) {
e.Cursor = Cursors.No;
e.Handled = true;
}
}
Note
Run the XtraTreeList or XtraGrid demo and click Open Solution for more examples.