Back to Devexpress

DragDropBehavior Class

windowsforms-devexpress-dot-utils-dot-dragdrop-50609abf.md

latest4.0 KB
Original Source

DragDropBehavior Class

Represents the Drag-and-Drop Behavior that can be attached to a data control to allow users to move/reorder data elements with the mouse.

Namespace : DevExpress.Utils.DragDrop

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
public sealed class DragDropBehavior :
    DragDropBehaviorBase<IDragDropBehaviorSource, DragDropBehaviorProperties>
vb
Public NotInheritable Class DragDropBehavior
    Inherits DragDropBehaviorBase(Of IDragDropBehaviorSource, DragDropBehaviorProperties)

Remarks

Use the BehaviorManager.Attach method to assign the behavior to a control in code or the BehaviorManager.Detach method to remove it. The code below shows how to assign the behavior to two grids, specify options, and add event handlers.

csharp
using DevExpress.Utils.Behaviors;
using DevExpress.Utils.DragDrop;

BehaviorManager behaviorManager1 = new BehaviorManager(this.components);

//To assign the Behavior to a control in code, use the Attach method.
behaviorManager1.Attach<DragDropBehavior>(gridView1, behavior => {
    behavior.Properties.AllowDrop = true;
    behavior.Properties.InsertIndicatorVisible = true;
    behavior.Properties.PreviewVisible = true;
    behavior.DragDrop += Behavior_DragDropToGrid1;
});

behaviorManager1.Attach<DragDropBehavior>(gridView2, behavior => {
    behavior.Properties.AllowDrop = false;
    behavior.Properties.InsertIndicatorVisible = false;
    behavior.Properties.PreviewVisible = false;
    behavior.DragDrop += Behavior_DragDropToGrid2;
});

//To remove the Behavior, use the Detach method.
behaviorManager1.Detach<DragDropBehavior>(gridView1);
behaviorManager1.Detach<DragDropBehavior>(gridView2);
vb
Imports DevExpress.Utils.Behaviors
Imports DevExpress.Utils.DragDrop

Dim behaviorManager1 As New BehaviorManager(Me.components)

'To assign the Behavior to a control in code, use the Attach method.
behaviorManager1.Attach(Of DragDropBehavior)(gridView1, Sub(behavior)
    behavior.Properties.AllowDrop = True
    behavior.Properties.InsertIndicatorVisible = True
    behavior.Properties.PreviewVisible = True
    AddHandler behavior.DragDrop, AddressOf Behavior_DragDropToGrid1
End Sub)

behaviorManager1.Attach(Of DragDropBehavior)(gridView2, Sub(behavior)
    behavior.Properties.AllowDrop = False
    behavior.Properties.InsertIndicatorVisible = False
    behavior.Properties.PreviewVisible = False
    AddHandler behavior.DragDrop, AddressOf Behavior_DragDropToGrid2
End Sub)

'To remove the Behavior, use the Detach method.
behaviorManager1.Detach(Of DragDropBehavior)(gridView1)
behaviorManager1.Detach(Of DragDropBehavior)(gridView2)

Inheritance

Object DevExpress.Utils.MVVM.BehaviorBase DevExpress.Utils.Behaviors.Behavior DevExpress.Utils.Behaviors.Behavior<DevExpress.Utils.DragDrop.IDragDropBehaviorSource> DevExpress.Utils.Behaviors.BehaviorWithEvents<DevExpress.Utils.DragDrop.IDragDropBehaviorSource> DragDropBehaviorBase<DevExpress.Utils.DragDrop.IDragDropBehaviorSource, DragDropBehaviorProperties> DragDropBehavior

See Also

Drag-and-Drop Behavior

DragDropBehavior Members

DevExpress.Utils.DragDrop Namespace