-1
private void dataGridViewSubLocation_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
    {
        //string id = dataGridViewSubLocation.SelectedRows[e.RowIndex].Cells[0].Value.ToString();
         id = Convert.ToInt32(dataGridViewSubLocation.SelectedRows[e.RowIndex].Cells[0].Value);
        masterLocComboBox.Text = dataGridViewSubLocation.SelectedRows[e.RowIndex].Cells[1].Value.ToString();
        txtLocName.Text = dataGridViewSubLocation.SelectedRows[e.RowIndex].Cells[2].Value.ToString();
        txtLocAddress.Text = dataGridViewSubLocation.SelectedRows[e.RowIndex].Cells[3].Value.ToString();
    }

........... here i;m using row index but still giving error.

  • 1
    You should include code in your question, not as a screenshot. Anyway, you either have no selected rows or no cells. You might want to check the event args to see if you can locate the cell. – ProgrammingLlama Nov 14 '19 at 08:33

1 Answers1

0

Assuming your grid view has three columns, the only reason for the exception can be that no rows are selected when the grid is double clicked. You need to make sure that SelectedRows.Count > 0.

StefanFFM
  • 1,526
  • 1
  • 14
  • 25