[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Selection
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus and Navigation
   [Expand]Conditional Formatting
   [Collapse]Drag-and-Drop
     Drag-and-Drop Options
     Drag-and-Drop Within GridControl
     Drag-and-Drop Between GridControl and ListBoxEdit
     Drag-and-Drop Between GridControls
     Drag-and-Drop Between GridControl and Other Controls
     Drag-and-Drop Between Applications
     Drag-and-Drop Hint
     Drop Marker
     Drag-and-Drop Managers
     Examples
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard 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 Between GridControl and Other Controls

The GridControl allows dragging records and dropping them in external controls. This topic demonstrates how to implement drag-and-drop between the GridControl and other controls that do not have a built-in drag-and-drop functionality.

The following image shows dragging records to and from the custom TextBlock:

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T566741.

Follow the steps below to implement drag-and-drop between the GridControl and the custom TextBlock:

Expanded Steps 1-2. Add Controls

  1. Add the GridControl to your project's window:

  2. Add the TextBlock to your project's window. The code sample below demonstrates the TextBlock with custom settings:

Expanded Steps 3-6. Implement Drag-and-Drop from the GridControl to the TextBlock

  1. Set the DataViewBase.AllowDragDrop property to true to enable drag-and-drop in the GridControl:

  2. Set the UIElement.AllowDrop property to true to allow dropping records in the TextBlock.

  3. Process dropped data and specify the TextBlock's content:

  4. You can add actions that are performed during dragging. Use the DragDrop.DragEnter and DragDrop.DragLeave events on the TextBlock to indicate a drop target. The code sample below demonstrates how to change the TextBlock's background color when dragging records into/out of the TextBlock:

Expanded Steps 7-9. Implement Drag-and-Drop from the TextBlock to the GridControl

  1. The TextBlock can be a drag source. Complete the following tasks to initiate a drag-and-drop operation:

    The code sample below demonstrates how to initiate a drag-and-drop operation when the TextBlock is clicked. The TextBlock's data context is used as the data to be transferred:

  2. Now you can drag data from the TextBlock but not drop it in the GridControl. Perform the following steps to allow dropping:

  3. Complete the following actions to process dropped data:

Expanded See Also

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