I'm using a DataGridView to display data, in the FullRowSelect mode.
My code follows:
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.SelectedRows)
{
currentColumn1Value = row.Cells[0].Value.ToString();
currentColumn2Value = row.Cells[1].Value.ToString();
//do something with the values
}
}
The view has only 2 columns and if the cell in the left column is selected, it returns the values. But, if I select the row by clicking in the right column, the values read empty.
What is the best way extract the selected cell values using this row selection method?