用大数据填充 DataGridView 时性能低下 [英] Slow performance in populating DataGridView with large data

查看:16
本文介绍了用大数据填充 DataGridView 时性能低下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 BindingSource 控件 (参考此处) 来填充我的 DataGridView 控件.上面有大约 1000 多条记录.我正在使用线程来这样做.在这种情况下,DataGridView 的执行速度非常慢.

I am using a BindingSource control (reference here) to populate my DataGridView control. There are around 1000+ records populating on it. I am using threading to do so. The DataGridView performs very slow in this case.

我尝试将 DoubleBuffered 属性设置为 true,RowHeadersWidthSizeMode 设置为禁用,AutoSizeColumnsMode 设置为无.但还是一样的行为.

I tried to set DoubleBuffered property to true, RowHeadersWidthSizeMode to disabled, AutoSizeColumnsMode to none. But still the same behavior.

请帮我解决这个问题.如何提高网格的性能.

Please assist me in this. How can I improve the performance of the Grid.

提前致谢,
维杰

Thanks in advance,
Vijay

推荐答案

如果您有大量的行,例如 10,000 和更多,为避免性能泄漏 - 在数据绑定之前执行以下操作:

If you have a huge amount of rows, like 10,000 and more, to avoid performance leaks - do the following before data binding:

dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing; 
// or even better, use .DisableResizing. Most time consuming enum is DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders

// set it to false if not needed
dataGridView1.RowHeadersVisible = false;

数据绑定后,您可以重新启用.

After the data is bound, you may re-enable it.

这篇关于用大数据填充 DataGridView 时性能低下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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