On DataGridView.SelectionChanged Event
Write the following code:-
private void DataGridView1_SelectionChanged(object sender, EventArgs e)
{
if( DataGridView1.SelectedRows.Count = 0 )
{
TextBox1.Value = DataGridView1.SelectedRows(0).Cells(0).Value;
TextBox2.Value = DataGridView1.SelectedRows(0).Cells(1).Value;
}
}
Make sure that SelectionMode Property of DataGridView is set to FullRowSelect for this to work.