TreeList.BeforeDropNode Event

Fires when a node is about to be dropped, and allows you to cancel the operation.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

[DXCategory("DragDrop")]
public event BeforeDropNodeEventHandler BeforeDropNode
<DXCategory("DragDrop")>
Public Event BeforeDropNode As BeforeDropNodeEventHandler

Event Data

The BeforeDropNode event's data class is DevExpress.XtraTreeList.BeforeDropNodeEventArgs.

Remarks

TreeList control nodes can be moved using drag-and-drop operations if the TreeListOptionsDragAndDrop.DragNodesMode option (accessible through the TreeList.OptionsBehavior property) is set to Single or Multiple.

The BeforeDropNode event fires when a node is about to be dropped, and allows you to cancel the operation. The BeforeDropNodeEventArgs.SourceNode property allows you to determine the node being processed. To get the destination parent node, read the DestinationNode property.

Unlike the TreeList.BeforeDragNode event, which allows you to cancel a drag-and-drop operation when it starts, the BeforeDropNode event allows you to cancel the operation when the node being dragged is about to be dropped. The code snippet below shows how to prohibit dropping nodes onto parent nodes that correspond to a particular condition.


private void treeList1_BeforeDropNode(object sender, DevExpress.XtraTreeList.BeforeDropNodeEventArgs e){
    if (e.DestinationNode.HasChildren == false) e.Cancel = true;
}

After the BeforeDropNode event is fired, the TreeList.AfterDropNode event fires.

See Also