you can use
CellContentClick Event of DataGridView.
Hope this will help you.
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
txtName.text=DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
}