TreeList.BeforeDragNode Event

Fires when an attempt to drag a node is performed.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v21.1.dll


public event BeforeDragNodeEventHandler BeforeDragNode

Event Data

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

Property Description
CanDrag Gets or sets a value indicating whether a Tree List node can be dragged.
Node Gets the current Tree List node. Inherited from NodeEventArgs.
Nodes Gets the list of nodes that are about to be dragged.
PreviewImage Gets or sets the image displayed near the mouse cursor during a drag-and-drop operation.


Node drag-and-drop can be enabled with the TreeListOptionsDragAndDrop.DragNodesMode setting. The result of drag and drop operations performed over nodes is specified by the TreeListOptionsBehavior.AutoChangeParent and TreeListOptionsDragAndDrop.CanCloneNodesOnDrop options.

Each time an attempt to drag a node is made, the BeforeDragNode event fires. You can use this event to specify whether the node can be dragged. The BeforeDragNodeEventArgs.CanDrag event’s parameter must be set to false to prohibit node dragging. The node which is about to be dragged can be identified via the NodeEventArgs.Node parameter.

You may also want to perform specific actions each time a drag and drop operation has been canceled or successfully finished. This can be performed using the TreeList.AfterDragNode and TreeList.DragCancelNode events respectively.


The following sample code prohibits parent node dragging. The TreeList.BeforeDragNode event is handled for this purpose. The TreeListNode.HasChildren property is used to identify whether the currently processed node has child nodes.

using DevExpress.XtraTreeList;

private void treeList1_BeforeDragNode(object sender, BeforeDragNodeEventArgs e) {
   if (e.Node.HasChildren) e.CanDrag = false;
See Also