0

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?

Cody Zink
  • 189
  • 1
  • 1
  • 7
  • 1
    Don't use the `CellContentClick` unless you mean it. It fires only if, yup, you can guess it now, you actually hit the cell's __content__. Use the `CellClick` instead! – TaW Jul 28 '14 at 18:19
  • Wow... how did I miss that? Thank you!!! – Cody Zink Jul 28 '14 at 19:57

0 Answers0