如何在datagridview中停止闪烁 [英] How to stop flickering in datagridview

查看:99
本文介绍了如何在datagridview中停止闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用datagridview来通过绑定数据库来显示来自访问数据库的数据。

I am using datagridview to display data from an access database by binding the database like this

      DataGridView.DataSource = dTable;

当我通过在datagridview中滚动来向下移动光标,当它更新时,滚动条自动上升,行中的第一个单元格被突出显示。在gridview中有超过300行。如果我想看到最后一个脚本,它会自动占用我,并且每隔5秒更新datagridview。

When i am moving my cursor down by scrolling in the datagridview,when it gets update, the scrollbar automatically goes up and the 1st cell in the row gets highlighted. there are more than 300 rows in the gridview.If i want to see the last scrip it automatically take me up and onemorething the datagridview is updated for every 5 seconds.

我不要滚动条上去,我想要我的滚动条,我在更新之前放置它。

I dont want the scroll bar to go up i want my scroll bar where i placed it before after updating also.

感谢提前。

推荐答案

这个讨论你会发现几个选项:


  1. 在刷新的功能DataTable在刷新之前,获取当前行(id)并将其存储在变量中。刷新之后,找到该行并滚动到它。

  1. In the function that refreshes the DataTable, just before refreshing, get the current row (id) and store it in a variable. After refreshing find that row and scroll to it.

您还可以在更新之前存储VerticalScrollingOffset(和Horizo​​ntalScrollingOffset),但这会在添加行或者删除当前行的上方。

You could also store the VerticalScrollingOffset (and HorizontalScrollingOffset) before updating but that will mess up when rows are added or deleted above the current row.

这篇关于如何在datagridview中停止闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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