Scroll to bottom of C# DataGridView

Motumbo picture Motumbo · Apr 2, 2012 · Viewed 48.5k times · Source

I'm trying to scroll to bottom of a DataGridView in a C# WinForm.

This code works with a TextBox:

textbox_txt.SelectionStart = textbox_txt.Text.Length;
textbox_txt.ScrollToCaret();

... but I don't know how to do it with a DataGridView. Any help, please?

Answer

Mark Hall picture Mark Hall · Apr 2, 2012

To scroll to bottom of DataGridView try this.

dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount-1;