This example demonstrates how to attach the Drag And Drop Behavior to the TreeList and Grid controls to allow users to move rows from the Grid to the TreeList with the mouse.
In this example:
-
The
InitDragDrop()
method creates the Behavior Manager and attaches the Drag and Drop Behavior to the TreeList and GridView:void InitDragDrop() { BehaviorManager behaviorManager1 = new BehaviorManager(this.components); behaviorManager1.Attach<DragDropBehavior>(gridView, behavior => { behavior.Properties.AllowDrop = false; behavior.Properties.InsertIndicatorVisible = true; behavior.Properties.PreviewVisible = true; }); behaviorManager1.Attach<DragDropBehavior>(treeList, behavior => { behavior.Properties.AllowDrop = true; behavior.Properties.InsertIndicatorVisible = true; behavior.Properties.PreviewVisible = true; behavior.DragOver += OnDragOver; behavior.DragDrop += OnDragDrop; }); }
-
The bahavior's
DragOver
andDragDrop
events are handled to customize drag-and-drop operations.
Note
A drag-and-drop operation is initiated when a user clicks a row. If there is a cell editor beneath the mouse pointer, it intercepts mouse events and cancels the drag-and-drop operation. To prevent this, the GridView's EditorShowMode property is set to
Click
.gridView.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click;
- Drag and Drop Appointments from the Grid Control to Scheduler
- DevExpress WinForms Cheat Sheet - Drag-and-Drop Within/Between Controls
- DevExpress WinForms Troubleshooting - Grid Control
(you will be redirected to DevExpress.com to submit your response)