windowsforms-devexpress-dot-utils-dot-dragdrop-dot-dragdropevents-4dfedb77.md
Occurs when a drag-and-drop operation is initiated.
Namespace : DevExpress.Utils.DragDrop
Assembly : DevExpress.Utils.v25.2.dll
NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core
[DXCategory("DragDrop")]
public event BeginDragDropEventHandler BeginDragDrop
<DXCategory("DragDrop")>
Public Event BeginDragDrop As BeginDragDropEventHandler
The BeginDragDrop event's data class is BeginDragDropEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Cancel | Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs. |
| Data | Gets or sets the dragged data elements. |
| PreviewImage | Gets or sets a preview of dragged data elements (rows/nodes/items). |
Users can start a drag operation with a click or double click on a non-editable row/node cell or row/node indicator. In multi-select mode, users can only use indicators to drag and drop if they are not used to select rows/nodes.
This example shows how to cancel a drag operation for a specific tree list node.
//You can cancel a drag-and-drop operation.
private void DragDropEvents2_BeginDragDrop(object sender, BeginDragDropEventArgs e) {
//If the source control is a tree list,
//the Data argument contains the collection of tree list nodes being dragged.
List<TreeListNode> list = e.Data as List<TreeListNode>;
if (list.Find((x) => x.GetValue(colDEPARTMENT1).ToString().Contains("Finance")) != null) {
//Set Cancel to true to prohibit the operation.
e.Cancel = true;
}
}
'You can cancel a drag-and-drop operation.
Private Sub dragDropEvents1_BeginDragDrop(ByVal sender As Object, ByVal e As DevExpress.Utils.DragDrop.BeginDragDropEventArgs) _
Handles dragDropEvents1.BeginDragDrop
'If the source control is a tree list,
'the Data argument contains the collection of tree list nodes being dragged.
Dim list As List(Of TreeListNode) = TryCast(e.Data, List(Of TreeListNode))
If list.Find(Function(x) x.GetValue(colDEPARTMENT1).ToString().Contains("Finance")) IsNot Nothing Then
'Set Cancel to true to prohibit the operation.
e.Cancel = True
End If
End Sub
Note
Run the XtraTreeList or XtraGrid demo and click Open Solution for more examples.
See Also