DataGridView 在更新和重新加载后保留选定的索引和滚动位置 [英] DataGridView Preserve Selected Index and Scroll Position after update and reload

查看:20
本文介绍了DataGridView 在更新和重新加载后保留选定的索引和滚动位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题,现在不知道如何在 DataGridView 中保留滚动位置.

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

我有超过 1000 行,滚动回编辑过的行很痛苦.刷新数据后如何保留滚动位置并滚动到已编辑的行?

I have over 1000+ rows and scrolling back to edited row is painful. How can I preserve the scroll position and scroll to the edited row after refreshing data?

推荐答案

保存行索引,进行刷新,然后设置 FirstDisplayedScrollingRowIndex 属性.

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

int index = dataGridView1.CurrentRow.Index;

/*
 * Your Refresh Code
 */

dataGridView1.FirstDisplayedScrollingRowIndex = index;

这篇关于DataGridView 在更新和重新加载后保留选定的索引和滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆