0
Answer

Drag & drop from listView to dataGrid

lameri

lameri

19y
3.1k
1
Hello,

This will be an easy question (I'm just a beginner). I'm setting up the event handlers and I don't know how to retrieve the dragged item. e. See my question below (in red).

private void listView_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)

{

DoDragDrop( e.Item, DragDropEffects.Copy | DragDropEffects.Move );
}

I'm not sure how to use the info dragged in the dataGrid...

private void dataGrid_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)

{

// Previous definitions...
// private DataTable customerTable = new DataTable("customerTable");

// Added 3 columns.
// dataGrid.DataSource = customerTable;


customerTable.Rows.Add(What do I put here?)

}

The e.Item that is dragged seems to be just having the contents of the first column, not the second and third??

Thank you!