解决dev GridControl 刷新数据后,滚动条恢复原来位置

找了半天scroll,结果却是TopRowIndex的事。
1、触发GridView_TopRowChanged()事件

 

 2、设置TopRowIndex

       int topIndex = -1;
       private void gridView2_TopRowChanged(object sender, EventArgs e)
        {
            topIndex = gridView2.TopRowIndex;
        }
        private void refreshView2()
        {
            string sql = "select * from [A数据分析表]";
            DataTable dt= db.GetTable(sql);
            gridControl2.DataSource = dt;
            gridView2.TopRowIndex = topIndex;//就是这句
        }

        private void button1_Click(object sender, EventArgs e)
        {
            refreshView2();
        }

 

posted on 2021-07-06 07:50  hushzhang  阅读(578)  评论(0编辑  收藏  举报

导航