PDA

View Full Version : Get the Selected Rows in the Windows Forms DataGridView



javad_r_85
یک شنبه 28 فروردین 1390, 11:22 صبح
Hi.
i want return selected rows in program .grid is bind database and return zero for selected rows

i dont know, please help me

javad_r_85
یک شنبه 28 فروردین 1390, 12:09 عصر
i use from this Code but return 0 .i thouth becuse bind to database return 0




foreach (DataGridViewRow r in dgvCourrse.SelectedRows)
{
MessageBox.Show(r.Cells[0].Value.ToString());
MessageBox.Show(dgvCourrse.SelectedRows[i].Cells[0].Value.ToString());

}


if (dgvCourrse.SelectedRows.Count ==0)
MessageBox.Show("0ok");

// MessageBox.Show (dgvCourrse.SelectedRows[i].Cells[0].Value.ToString());

if (dgvCourrse.Rows[i].Selected )
MessageBox.Show (dgvCourrse.Rows[i].Cells[0].Value.ToString());