Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoscroll in DataGridView

It's possible to perform autoscroll when I add value to a cell below last visible row on form? I cannot find any autoscroll properties in DataGridView. Is the only possible way to do this to find index of the last visible cell and change FirstDisplayedScrollingRowIndex?

like image 994
spyder Avatar asked Nov 29 '12 08:11

spyder


3 Answers

You can use the FirstDisplayedCell property to make that cell displayed.
Since you know which cell you added the value to, you can do it like this:

dataGridView1.FirstDisplayedCell = yourCell
like image 109
Blachshma Avatar answered Sep 20 '22 15:09

Blachshma


Can try this,

gv.FirstDisplayedCell = gv.Rows[gv.Rows.Count - 1].Cells[0];
like image 29
noobie Avatar answered Sep 18 '22 15:09

noobie


These 3 lines are really equivalent to an auto scroll down

System.Int16 i_NotDisplayableRowCount = dataGridView1.RowCount - dataGridView1.DisplayedRowCount(false); // false means partial rows are not taken into acount
if (i_NotDisplayableRowCount > 0)
    dataGridView1.FirstDisplayedScrollingRowIndex = i_NotDisplayableRowCount;
like image 28
RawBean Avatar answered Sep 19 '22 15:09

RawBean