@Steve Clark , Welcome to Microsoft Q&A, we also need to set the textBox1_DragDrop event if we want to drag data from datagirdview to textbox.
Here is a code example you could refer to.
private void Form1_Load(object sender, EventArgs e)
{
List<Student> list = new List<Student>();
list.Add(new Student { Name="test1" });
dataGridView1.DataSource=list;
dataGridView1.AllowDrop= true;
textBox1.AllowDrop= true;
}
private void textBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(DataGridViewSelectedRowCollection)))
{
e.Effect = DragDropEffects.Move;
}
}
private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
{
dataGridView1.DoDragDrop(dataGridView1.SelectedRows, DragDropEffects.Move);
}
private void textBox1_DragDrop(object sender, DragEventArgs e)
{
DataGridViewSelectedRowCollection rows = (DataGridViewSelectedRowCollection)e.Data.GetData(typeof(DataGridViewSelectedRowCollection));
foreach (DataGridViewRow row in rows)
{
textBox1.Text = row.Cells[0].Value.ToString();
}
}
Note: Please select the datagirdview row first of all and do the dragdrop operation.
Tested result:
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.