Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Expand]Data Binding Common Concepts
  [Expand]Data Source Wizard
  [Expand]Expressions
  [Collapse]Behaviors
    File and Folder Browser Behaviors
    Persistence Behavior
    Indicator Behaviors
    Stub Glyph Behavior
    Banner Behavior
    Drag And Drop Behavior
    Magnifier Behavior
    Snap Window Behavior
  [Expand]Application Appearance
  [Expand]Filtering UI Context
  [Expand]High DPI Support
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML Text Formatting
  [Expand]Menus
  [Expand]Tooltip Management
  [Expand]Saving and Restoring Layouts
   Clipboard - Copy and Paste Operations. Data Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Drag And Drop Behavior

The Drag and Drop Behavior allows you to add support for drag-and-drop operations between controls.

Supported controls

Behavior options

  • Target—specifies the control to which the behavior is attached;
  • PreviewVisible—specifies whether a preview of item(s) being dragged is displayed during operation;
  • InsertIndicatorVisible—specifies whether the indicator is showing items' insertion position;
  • AllowDrop—specifies whether the attached control allows an end-user to drop the item(s) on it.

The code below shows how to assign a Drag and Drop Behavior to a control using the BehaviorManager.Attach method and specify its options.

Note

Drag and Drop Behaviors should be attached to the source and target controls to work correctly. Disable the source control's AllowDrop setting to allow data to be transferred one way only.

Note

For a grid control with master-detail data presentation, attach a Drag and Drop Behavior to the main view (see GridControl.MainView).

Important

Business objects must have a default constructor with no parameters if the behavior is attached to data-aware controls that store these objects defined in code. Otherwise, rows that display these objects cannot be moved between controls.

Behavior events

  • BeginDragDrop—occurs when a drag-and-drop operation starts allowing you to cancel the operation, or provide a custom preview image;
  • DragEnter—occurs when an object is dragged into the control's bounds;
  • DragOver—occurs when an object is dragged over the control's bounds;
  • DragLeave—occurs when an object is dragged out of the control's bounds;
  • DragDrop—occurs when a drag-and-drop operation is completed;
  • EndDragDrop—allows you to perform custom actions after a drag-and-drop operation is completed.

A DragDropEvents component is automatically added to your form when you attach a Drag and Drop Behavior to a control at design time. You can use this component to subscribe to the behavior's events.

When handling the drag and drop events for a GridView, use the following static (Shared in VB) methods to calculate GridView-specific arguments:

  • DragOverGridEventArgs.GetDragOverGridEventArgs—for the DragOver event;
  • DragDropGridEventArgs.GetDragDropGridEventArgs—for the DragDrop event.
Note

The Handled event argument should be set to true for event handlers to be in effect.

Is this topic helpful?​​​​​​​