datagridview1 to datagridview2
-
hi, my problem is how to select data from datagridview1 and transfer the selected data by double clicking the row to datagridview2? my code: private void dataGridView3_DoubleClick(object sender, EventArgs e) { long itemcode =0; string description = ""; itemcode = Convert.ToInt64(dataGridView3.Rows[dataGridView3.CurrentRow.Index].Cells[0].Value.ToString()); description = dataGridView3.Rows[dataGridView3.CurrentRow.Index].Cells[1].Value.ToString(); DataGridViewCell itemCodeCell = new DataGridViewTextBoxCell(); itemCodeCell.Value = itemcode; DataGridViewCell descriptionCell = new DataGridViewTextBoxCell(); descriptionCell.Value = description; DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(itemCodeCell); row.Cells.Add(new DataGridViewTextBoxCell()); row.Cells.Add(new DataGridViewTextBoxCell()); row.Cells.Add(descriptionCell); string[] rows = new string[]{ itemcode.ToString(), "", "", description }; dataGridView4.Rows.Add(rows); } it seems that my program is correct but i receive an exception error on the last part of my code... dataGridView4.Rows.Add(rows); Exception error message received: Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound. what will i do??pls. help.. jing
jing