我正在构建一个Windows窗体应用程序,我想在哪里打开窗体,如产品,它应该加载数据库中可用的所有列出的产品。随着照片。并在DataGridView中显示它。 现在我的问题是在gridview中加载这么多数据的最佳方式是什么?Windows窗体DataGridView快速加载
-2
A
回答
0
如果要显示DataGridView
中的数据,并且您怀疑会有大量数据(可能太多以至于将其完全加载到内存中可能会出现问题),则应该使用其功能VirtualMode
。请参阅MSDN文章,"Walkthrough: Implementing Virtual Mode in the Windows Forms DataGridView Control":
“当你想在DataGridView控件来显示非常大量的表格数据,可以VirtualMode属性设置为true,并明确其数据存储管理控制的互动此。可以让您在这种情况下调整控件的性能。“
基本上,虚拟模式意味着DataGridView
控件将在需要数据时提高CellValueNeeded
event。您订阅该事件的处理程序并“及时”获取所需数据。这样就可以将全部数据集的一小部分保留在内存中。
这取决于你在内存中保存了多少数据记录。一些可能的策略:
您执行分页,即从数据库加载连续行的块。这需要一个已知的顺序。也就是说,您需要能够从
DataGridView
的当前排序中派生出ORDER BY
SQL子句。 (请查看"Using OFFSET and FETCH to limit the rows returned"以了解如何在SQL级别实现分页。)您从数据库中获取单个行。这可能比分页效率低,但如果无法确定与您的
DataGridView
当前排序标准相匹配的ORDER BY
子句,则效果会更好。
在这两种情况下,请查看我链接到上面的文章,了解如何使用虚拟模式的教程。
相关问题
- 1. WPF DataGrid与Windows窗体DataGridView
- 2. 在Windows窗体刷新DataGridView
- 3. Windows窗体(C#):DataGridView的System.IndexOutOfRangeException
- 4. C#DataGridView和Windows窗体
- 5. Windows窗体DataGridView滚动
- 6. Windows窗体不加载
- 7. VB 2013从窗体中加载datagridview
- 8. 基于Windows的Windows窗体加载
- 9. 快速更新DataGridView
- 10. 快速ArrayList加载
- 11. Windows窗体/ DatagridView屏幕闪烁
- 12. Windows窗体DataGridView自动调整
- 13. Windows窗体 - 验证DataGridView的输入
- 14. 动态绑定Windows窗体中的DataGridView
- 15. 使用C#的Windows窗体中的DataGridView
- 16. Windows窗体:DataGridView绑定问题
- 17. Windows窗体:DataGridView中的额外列
- 18. Windows窗体中的DataGridView中的UserControl
- 19. 不排序的Windows窗体DataGridView
- 20. 如何在Windows窗体中实现快速更新表?
- 21. Windows窗体Aplication文件加载异常
- 22. Windows窗体加载然后退出
- 23. Windows窗体Tabpage加载缓慢
- 24. 加载后立即关闭windows窗体
- 25. 在Windows窗体中加载图像
- 26. C#Windows窗体永远加载
- 27. 设置DataGridView快速行高
- 28. 谁在Windows窗体程序中调用窗体加载事件?
- 29. 快速加载网页
- 30. 加载JSON图像快速
数据虚拟化。您还可以提高控件的性能(请参阅,例如[this](http://stackoverflow.com/q/4255148/1997232))。但是,如果问题得不到解决,问问题还为时过早。你有尝试过什么吗?你不满意什么? – Sinatr
电网的性能。当我加载这么多的数据时(gui)会被挂起很多 – Siraj