I have a data grid view with checkbox column as the 1st column. What we want is when user checked rows, all the checked rows should goes to textboxes in another Form. I wrote followings to do that. But the problem is although checked more than 1 row, always it sends the last checked row data to the next form. Not all checked rows data
private void btngnvoucher_Click(object sender, EventArgs e)
{
// foreach(DataGridViewRow row in dataGridView1.Rows)
for (int x = 0; x < dataGridView1.RowCount;x++ )
{
// DataGridViewCheckBoxCell ch1 = (DataGridViewCheckBoxCell)row.Cells[0];
DataGridViewCheckBoxCell ch1 = (DataGridViewCheckBoxCell)dataGridView1.Rows[x].Cells[0];
if (ch1.Value != null)
{
for (int a = 0; a < 6; a++)
{
for (int col = 1; col < 5; col++)
{
TextBox theText1 = (TextBox)vobj.Controls[col - 1];
// theText1.Text = row[x].Cells[col].Value.ToString();
theText1.Text = dataGridView1.Rows[x].Cells[col].Value.ToString();
}
// a = a + 1;
break;
}
}
}
vobj.Show();
}
}
}
Can any one tell me what I can do to solve this?
Instead of this:
try: