Note
In v17.2+, you can attach Drag And Drop Behavior to Grid controls to enable drag-and-drop without writing additional code.
This example demonstrates how to use traditional Drag events to allow users to drag data rows from one grid and drop them onto another grid control.
Files to Review
Documentation
See Also
- DevExpress WinForms Cheat Sheet - Drag-and-Drop Within/Between Controls
- DevExpress WinForms Troubleshooting - Grid Control
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
C#using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
using System;
using System.Data;
namespace DragDropTwoGrids {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
}
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
DataTable table = FillTable();
SetUpGrid(gridControl1, table);
SetUpGrid(gridControl2, table.Clone());
}
public DataTable FillTable() {
DataTable table = new DataTable();
table.Columns.Add("Column");
for (int i = 1; i <= 5; i++)
table.Rows.Add(new object[] { "Item " + i.ToString() });
return table;
}
public void SetUpGrid(GridControl grid, DataTable table) {
GridView view = grid.MainView as GridView;
grid.DataSource = table;
view.OptionsBehavior.Editable = false;
}
}
}