Handle the DataGridView.SelectionChanged event:
private void myDataGridView_SelectionChanged(object sender, EventArgs e)
{
DataGridView dgv = sender as DataGridView;
if (dgv != null && dgv.SelectedRows.Count > 0)
{
DataGridViewRow row = dgv.SelectedRows[0];
if (row != null)
{
myFirstTextBox.Text = row.Cells[0].Value.ToString();
mySecondTextBox.Text = row.Cells[1].Value.ToString();
}
}
}
You may want to set the DataGridView.SelectionMode to DataGridViewSelectionMode.FullRowSelect