سلا مهندسین و اساتید عزیز.
یه سوال داشتم و انتظار دارم پاسخ درست دریافت کنم.
میخوام از یک دیتاگرید که اطلاعاتش از دیتابیس گرفته میشه، با استفاده از چکباکس، سطرهایی که تیک دار میشن رو به دیتاگرید دیگه در فرم دیگری انتقال بدم.
یه چیزایی نوشتم.اما فقط یک سطر منتقل میشه.میخواستم راهنمایی کنین.سپاس فراوان
private void button1_Click(object sender, EventArgs e)
{
List<DataGridViewRow> selectedRows = (from row in dataGridView1.Rows.Cast<DataGridViewRow>()
where Convert.ToBoolean(row.Cells["check"].Value) == true
select row).ToList();
foreach (DataGridViewRow row in selectedRows)
{
{
Form1 frm= new Form1 ();
int i = 0;
DataGridViewRow r = new DataGridViewRow();
frm.dataGridView1.Rows.Add(r);
frm.dataGridView1.Rows[i].Cells["name"].Value = row.Cells["name"].Value.ToString();
frm.dataGridView1.Rows[i].Cells["family"].Value = row.Cells["family"].Value.ToString();
frm.dataGridView1.Rows[i].Cells["family"].Value = row.Cells["age"].Value.ToString();
i++;
this.Hide();
frm.ShowDialog();
}
}
}