there are a couple of articles on codeproject and google that address this issue
Drag and Drop between list boxes - Beginner's Tutorial[
^]
and particularly for datagridview ... its not that much different... this code might help you
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.dataGridView1.AllowDrop = true;
DataTable dtb = new DataTable();
dtb.Columns.AddRange(new DataColumn[] { new DataColumn(), new DataColumn(), new DataColumn() });
for (int i = 0; i < 30;)
{
dtb.Rows.Add((++i).ToString(), (++i).ToString(), (++i).ToString());
}
dataGridView1.DataSource = dtb;
}
private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
dataGridView1.DoDragDrop(dataGridView1[e.ColumnIndex,e.RowIndex].FormattedValue, DragDropEffects.Copy);
}
}
private void dataGridView1_DragDrop(object sender, DragEventArgs e)
{
string cellvalue=e.Data.GetData(typeof(string)) as string;
Point cursorLocation=this.PointToClient(new Point(e.X,e.Y));
System.Windows.Forms.DataGridView.HitTestInfo hittest= dataGridView1.HitTest(cursorLocation.X,cursorLocation.Y);
if (hittest.ColumnIndex != -1
&& hittest.RowIndex != -1)
dataGridView1[hittest.ColumnIndex, hittest.RowIndex].Value = cellvalue;
}
private void dataGridView1_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}
}
good luck