You'll laugh when I point out the problem.
Here is the modified code (I have changed a couple of your variable names to make it clearer):
int row1 = (this.agentsDataGridView.CurrentCell.RowIndex);
int col1 = (this.agentsDataGridView.CurrentCell.ColumnIndex);
this.agentsTableAdapter.Fill(assistReportsDataSet.Agents);
this.agentsDataGridView.CurrentCell = this.agentsDataGridView[col1, row1];
Did you spot the change?
The
CurrentCell
property expects the column first, then the row. :-D
Daft ain't it?
[Edit]
After your comment:
You might want to look at the
DataGridView.SelectedCells[
^] property.
You can iterate over that collection, reselecting them as you go:
DataGridViewSelectedCellCollection selCells = myDGV.SelectedCells;
RefreshData();
foreach (DataGridViewCell cell in selCells)
{
myDGV.Rows[cell.RowIndex].Cells[cell.ColumnIndex].Selected = true;
}
I have typed that in without benefit of Visual Studio, so please forgive any syntax errors, but it should give you the idea.
Good luck! :)
[/Edit]