【问题标题】:DataGridView - Load large number of data very slowDataGridView - 加载大量数据非常慢
【发布时间】:2014-09-11 17:23:39
【问题描述】:

我有一个带有 Datagridview 的表单,它将数据从 db 加载到绑定源,然后将绑定源设置为 DataSource of datagrid
我调用SuspendBinding() 并将RaiseListChangedEvents 设置为false,然后从db 填充数据,当数据填充调用ResumeBinding()ResetBindings(false) 并将RaiseListChangedEvents 设置为true

newPriceListSelectBindingSource.RaiseListChangedEvents = false;
newPriceListSelectBindingSource.SuspendBinding();
newPriceListSelectTableAdapter.Fill(dsOrders.NewPriceListSelect, null, int.Parse(trvCategory.SelectedNode.Name), Convert.ToInt32(numericUpDown1.Value));
newPriceListSelectBindingSource.RaiseListChangedEvents = true;
newPriceListSelectBindingSource.ResumeBinding();
newPriceListSelectBindingSource.ResetBindings(false);

在很多windows操作系统填完数据后,resetbindings(false)立即调用,但是在windows server 2008 r2这个方法调用非常非常慢(好像程序挂了)。
当然,我不确定这取决于 Windows。
数据行约 80000 行,20 列。
请帮我解决这个问题。

【问题讨论】:

  • 这可能是 Paging DataGrid Paging 问题而不是 binging 问题..?还有如何查看返回数据的查询.. 我还会考虑重构代码以基于日期过滤器仅加载一定数量的数据,然后如果用户需要查看更多数据,然后在您的流程中添加一些过滤..
  • @DJKRAZE 为什么resetbinding 只在某些窗口上很慢?
  • 你在问what or did you me WHY 看看这个SO 发布它会回答你的问题 标记接受的答案stackoverflow.com/questions/1145736/… 我认为如果你重新考虑这个过程,你可以真正简化你的问题并亲自进行一些重构..
  • @DJKRAZE 我想说为什么
  • 看看我评论中的链接,我建议在加载过程中不要启用数据网格,直到你完成绑定..我们也看不到在 DataGrid 时调用了哪些其他事件正在加载..

标签: c# winforms datagridview bindingsource


【解决方案1】:

我发现了问题
问题在于名为 DataGridViewColumn.AutoSizeMode 的网格列属性,因为其中一列的此属性的值是 AllCells,我将其更改为 DisplayedCells 并修复了问题。

【讨论】:

  • 终于经过了漫长的 3 年! :D
  • 不,我在 2 年前发现了问题,但我忘了回答我的问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-07-07
  • 1970-01-01
  • 1970-01-01
  • 2013-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多