0

I want gridview scrollbar to set at last row at gridview. For that purpose, i've used below solution.

dataGridView.FirstDisplayedScrollingRowIndex = dataGridView.SelectedRows[0].Index;

But this is not working. When i tried to debug i found that, FirstDisplayedScrollingRowIndex value gets reset in dataGridViewActivity_RowStateChanged event.

Nirav Parsana
  • 155
  • 1
  • 17

1 Answers1

0

Set the last row as the first visible row:

dataGridView1.FirstDisplayedScrollingRowIndex = 
dataGridView1.Rows.GetLastRow(DataGridViewElementStates.Visible);

Or set the last visible row as the first visible row:

dataGridView1.FirstDisplayedScrollingRowIndex = 
dataGridView1.Rows.GetLastRow(DataGridViewElementStates.Displayed);

Or move to the last selected row if it is not displayed:

if (dataGridView1.SelectedRows.Count > 0)
{
    dataGridView1.FirstDisplayedScrollingRowIndex = 
    dataGridView1.SelectedRows[dataGridView1.SelectedRows.Count - 1].Index;
}
Jimi
  • 29,621
  • 8
  • 43
  • 61