Fila seleccionada de DataGridView para mostrar en cuadros de texto

Fila seleccionada de DataGridView para mostrar en cuadros de texto

Puede usar la propiedad SelectedRows.

Ejemplo:

if(dataGridView1.SelectedRows.Count > 0) // make sure user select at least 1 row 
{
   string jobId = dataGridView1.SelectedRows[0].Cells[0].Value + string.Empty;
   string userId = dataGridView1.SelectedRows[0].Cells[2].Value + string.Empty;

   txtJobId.Text = jobId;
   txtUserId.Text = userId;
}

Agregar código en el evento cellclick

if (e.RowIndex >= 0)
{
    //gets a collection that contains all the rows
    DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
    //populate the textbox from specific value of the coordinates of column and row.
    txtid.Text = row.Cells[0].Value.ToString();
    txtfname.Text = row.Cells[1].Value.ToString();
    txtlname.Text = row.Cells[2].Value.ToString();
    txtcourse.Text = row.Cells[3].Value.ToString();
    txtgender.Text = row.Cells[4].Value.ToString();
    txtaddress.Text = row.Cells[5].Value.ToString();
}

Para obtener más información, use este enlace Cómo mostrar la fila seleccionada de Datagridview en el cuadro de texto usando C#