DragDropEvents.BeginDragDrop Event

Occurs when a drag-and-drop operation is initiated.

Namespace: DevExpress.Utils.DragDrop

Assembly: DevExpress.Utils.v20.1.dll

Declaration

[DXCategory("DragDrop")]
public event BeginDragDropEventHandler BeginDragDrop
<DXCategory("DragDrop")>
Public Event BeginDragDrop As BeginDragDropEventHandler

Event Data

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).

Remarks

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.

Examples

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;
    }
}
NOTE

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

See Also