虚拟模式下的空 Datagridview 具有数百万行,速度变慢

发布于 2024-08-12 17:02:31 字数 728 浏览 4 评论 0原文

我正在尝试创建连接到 sqlserver 的 datagridview。 但似乎即使在简单的 datagridview 中也无法快速处理数百万 行数。因此滚动到上行 datagridview 明显更新 更快,向下滚动到最后一行

可以看到效果:

    Public Class Form1   
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.
EventArgs) Handles Me.Load
   DataGridView1.VirtualMode = True
   DataGridView1.RowCount = 10000000
   DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
End Sub


Private Sub DataGridView1_CellValueNeeded(ByVal sender As Object, ByVal e
As System.Windows.Forms.DataGridViewCellValueEventArgs) Handles DataGridView1.
CellValueNeeded

e.Value = 1
   End Sub
End Class

''form contains datagridview with 3 columns

有没有解决方法?

I am trying to create datagridview connected to sqlserver.
But it seems that even in simple datagridview cannot handle quickly millions
of rows. And so scrolled to upper rows datagridview updates noticably
faster, that scrolled down to last row
.

The effect can be seen:

    Public Class Form1   
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.
EventArgs) Handles Me.Load
   DataGridView1.VirtualMode = True
   DataGridView1.RowCount = 10000000
   DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
End Sub


Private Sub DataGridView1_CellValueNeeded(ByVal sender As Object, ByVal e
As System.Windows.Forms.DataGridViewCellValueEventArgs) Handles DataGridView1.
CellValueNeeded

e.Value = 1
   End Sub
End Class

''form contains datagridview with 3 columns

Is there some workaround?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

匿名的好友 2024-08-19 17:02:31

您应该将有关自动调整行和列大小的任何选项设置为 false,并为行数据使用缓存(大小约为网格中显示的实际行数的 2 倍)请参阅 msdn

you should set to false any options regarding auto sizing of rows and columns and use a cache for your row data (of size about 2 times the actual number of rows displayed in the grid) see msdn

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文