如何将gridview行从一个网格拖动到另一个网格

我有一个行视图。 我希望用户能够抓住一行,并将其移动到winform上的其他几个网格视图之一。 我该怎么做呢? 我不熟悉如何在这里实现拖放。

关于这种拖放的任何好教程? 谢谢你的帮助。

更新:好的,我有以下代码(从gridPODetails拖到dataGridView1。它还没有工作,但我更接近(现在我得到拖动箭头和目的地的加号)。我错过了什么?

private void gridPODetails_MouseDown(object sender, MouseEventArgs e) { DataGridView.HitTestInfo info = gridPODetails.HitTest(eX, eY); if (info.RowIndex >= 0) { //DataRowView view = (DataRowView)gridPODetails.Rows[info.RowIndex].DataBoundItem; //WRONG DataRow view = ((DataTable)(gridPODetails.DataSource)).Rows[info.RowIndex]; //RIGHT if (view != null) { gridPODetails.DoDragDrop(view, DragDropEffects.Copy); } } } private void dataGridView1_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; } private void dataGridView1_DragDrop(object sender, DragEventArgs e) { DataGridView grid = sender as DataGridView; DataTable table = grid.DataSource as DataTable; DataRow row = e.Data.GetData(typeof(DataRow)) as DataRow; if (row != null && table != null && row.Table != table) { table.ImportRow(row); row.Delete(); } } 

已解决:请参阅上面的编辑。 我实际上抓住了整个数据表,而不仅仅是我想要的行。 当然,目的地只知道如何使用Rows,而不是整个表。 现在它的工作!

我在Bing搜索中找到了这个。 它看起来就像你正在寻找的。

http://tv.devexpress.com/Content/XtraGrid/XtraGridDragRowsBetweenGrids/XtraGridDragRowsBetweenGrids.pdf