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

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

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

 

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

 

上一篇:从零开始搭建Wpf基础11-实现一个业务菜单


下一篇:马云为何不投游戏?