I want to get value of row where checkbox is checked. I am new to C# windows forms and so far unsuccessful. I want to eventually use these row values, so if user selects multiple row and then I should get value for those checked. Also, I have set the selection mode to 'fullrowselect'
Please suggest changes to my code
private void button1_Click(object sender, EventArgs e)
{
StringBuilder ln = new StringBuilder();
dataGridView1.ClearSelection();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (dataGridView1.SelectedRows.Count>0 )
{
ln.Append(row.Cells[1].Value.ToString());
}
else
{
MessageBox.Show("No row is selected!");
break;
}
}
MessageBox.Show("Row Content -" + ln);
}