Working on a project involving the use of two datagridviews. The idea being that the user will select entries from one, hit a button, and it will add them to another. At the moment, I'm just trying to get one selected item to show up if added right. After that, I will work on looping. The code I tried is below. Returns OutOfRange exceptions when I run. How do I get it to properly store and add the values?
Code:int selectedRowIndex = ResultList.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = ResultList.Rows[selectedRowIndex]; DataGridViewRow NewRow = new DataGridViewRow(); NewRow.Cells[0].Value = selectedRow.Cells[0].Value; NewRow.Cells[1].Value = selectedRow.Cells[1].Value; NewRow.Cells[2].Value = selectedRow.Cells[2].Value; NewRow.Cells[3].Value = selectedRow.Cells[3].Value; NewRow.Cells[4].Value = selectedRow.Cells[4].Value; NewRow.Cells[5].Value = selectedRow.Cells[5].Value; NewRow.Cells[6].Value = selectedRow.Cells[6].Value; NewRow.Cells[7].Value = selectedRow.Cells[7].Value; NewRow.Cells[8].Value = selectedRow.Cells[14].Value; NewRow.Cells[9].Value = selectedRow.Cells[12].Value; QueueView.Rows.Add(NewRow);