I have a DataGridView in WinForms. I am programmatically setting the selected row using:
int index = CompoundListSource.Find("ID", previousAzeotrope.Compound1.ID);
CompoundListSource.Position = index;
For context:
BindingSource CompoundListSource = new BindingSource();
CompoundListSource.DataSource = [A DataTable];
The selection works fine. However, my DataGridView is rather large, so I have it calculate the row heights by listening to its Scroll event. When the DataGridView is scrolled, I call:
GridView.AutoResizeRows(DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders)
As a result of this resizing, the selected row is often no longer among the displayed rows.
It's not a serious problem, but it's a nuisance. Does anyone here know how to solve this problem?