Skip to content

DevExpress-Examples/drag-drop-grid-rows-to-treelist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Drag-and-Drop Grid Rows to the TreeList

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 and DragDrop 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;

Files to Review

Documentation

See Also

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)