gridView.FirstDisplayedScrollingRowIndex = gridView.SelectedRows[0].Index;
blowing up with:
No room is available to display rows
DataGridView is customized control in the unbound mode. datagridview.FirstDisplayedScrollingRowIndex is not set in a specific datagridview based event.
Rows are added to the datagridview via gatagridview.Rows.Add method on DataSet.EndMerge then cells are styled and formatted row by row. Last selected row is cleared and restored and scroll bar position restored to the first visible row.
Trying find out what this exception actually means.
if (gridView.Rows.Count > 0)
{
gridView.ClearSelection();
T value = GetItemByRow(gridView.Rows[0]);
bool isVisible = filter.ShouldShow(value);
gridView.Rows[0].Selected = true;
if (!isVisible)
{
gridView.Rows[0].Visible = true;
gridView.FirstDisplayedScrollingRowIndex = gridView.SelectedRows[0].Index;
gridView.Rows[0].Visible = false;
}
else
{
gridView.FirstDisplayedScrollingRowIndex = gridView.SelectedRows[0].Index;
}
}