How do I programmatically scroll a winforms datagridview control?

前端 未结 5 2127
旧时难觅i
旧时难觅i 2020-12-03 17:44

I\'m implementing some drag drop features in one my controls inheriting from a datagridview. Basically I\'m dragging a row from somewhere in the DGV and dropping it somewher

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 18:35

    Well, since this is a datagridview... Sorry for the 'winforms' in the question... but I could just do this.. scrolling up or down one row.

    Scroll up:

    this.FirstDisplayedScrollingRowIndex = this.FirstDisplayedScrollingRowIndex - 1
    

    Scroll Down:

    this.FirstDisplayedScrollingRowIndex = this.FirstDisplayedScrollingRowIndex + 1;
    

    You've gotta make sure to check that the numbers don't go out of bounds though.

提交回复
热议问题