Here's how to make sure the active line gets reselected after the refresh;
' --- Save the current row on the datagrid
Dim n_currentrow As Integer = DataGridView1.CurrentRow.Index
' --- refresh the grid content
Me.SomeTableAdapter.Fill(Me.SomeDataset.SomeSelection)
' --- Reselect the row that was active
DataGridView1.CurrentCell = DataGridView1.Rows(n_currentrow).Cells(1)
If you additionaly want a full row to be selected on click / return instead of a single cell being highlighted you can set the Selectionmode property of the grid to FullRowSelect (see below)
|