DataGridView Preserve Selected Index and Scroll Position after update and reload

后端 未结 2 465
悲哀的现实
悲哀的现实 2020-12-21 09:49

I have some problem, don\'t now how to preserve the scroll position in a DataGridView.

I have over 1000+ rows and scrolling back to edited row is painf

2条回答
  •  甜味超标
    2020-12-21 10:32

    Save the row index, do your refresh, then set the FirstDisplayedScrollingRowIndex property.

    int index = dataGridView1.CurrentRow.Index;
    
    /*
     * Your Refresh Code
     */
    
    dataGridView1.FirstDisplayedScrollingRowIndex = index;
    

提交回复
热议问题