Supposing the name of the datagridview is dgvGrid and Textbox name is txtName now:-
on click event of datagridview add the following code:-
if (dgvGrid.Rows.Count > 0 & dgvGrid.CurrentRow.Index>=0)
{
if (dgvGrid.Rows[dgvGrid.CurrentRow.Index].Cells[dgvGrid.CurrentCell.ColumnIndex].Value != null)
{
txtName.Text = dgvGrid.Rows[dgvGrid.CurrentRow.Index].Cells[dgvGrid.CurrentCell.ColumnIndex].Value.ToString();
}
}