marcoqf
6/9/2019 - 6:10 PM

Get the selected Rows from a DataGridView

foreach (DataGridViewRow r in dataGridView1.SelectedRows)
{
   //Code to add selected row to new datagrid.
   //Important to note that dataGridView2.Rows.Add(r) will not work 
   //because each row can only belong to one data grid.  You'll have 
   //to create a new Row with the same info for an exact copy
}

foreach (DataGridViewRow r in dataGridView1.SelectedRows)
{
  // If you wanted to move the items from one DataGridViewRow to the other 
  // [so that they could only exist in one list at a time] you could do this.
  dataGridView1.Rows.Remove(r);
  dataGridView2.Rows.Add(r);
}