其他分享
首页 > 其他分享> > 解决dev GridControl 刷新数据后,滚动条恢复原来位置

解决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();
        }

 

标签:void,object,private,滚动条,topIndex,dev,TopRowIndex,gridView2,GridControl
来源: https://www.cnblogs.com/hushzhang/p/14975177.html