I have written an application that is connected to SQL database in C#.There are two forms.
I have a DataGrid in the first form. There are those columns like ID,AD,SOYAD in Datagridview.
I have a DataGrid in the second form(frm4) and there are those columns like ID,AD,SOYAD in Datagridview.
I put ContextMenuStrip in the first DataGridView.
My question is:I want to add to second DataGridView those rows which are choosen in the first DataGridView.
frm4.dataGridView1.Rows[0].Cells[0].Value = dataGridView1.CurrentRow.Cells[0].Value.ToString();
frm4.dataGridView1.Rows[0].Cells[1].Value = dataGridView1.CurrentRow.Cells[1].Value.ToString();
frm4.dataGridView1.Rows[0].Cells[2].Value = dataGridView1.CurrentRow.Cells[2].Value.ToString();
I only can add one row with upper code. But,I want to add multiple rows. I’m using below code for that. But, it’s not working.
for (int i = 0; i < length; i++)
{
frm4.dataGridView1.Rows[0].Cells[0].Value = dataGridView1.CurrentRow.Cells[0].Value.ToString();
frm4.dataGridView1.Rows[0].Cells[1].Value = dataGridView1.CurrentRow.Cells[1].Value.ToString();
frm4.dataGridView1.Rows[0].Cells[2].Value = dataGridView1.CurrentRow.Cells[2].Value.ToString();
}
assume this is windows form application