除了数据表和数据视图之外,是否有更有效的(就内存占用而言)绑定到数据网格
除了数据表和数据视图之外,是否有更有效的(就内存占用而言)绑定到数据网格?
我有一个绑定到数据视图的数据网格,它似乎消耗了大量内存。有没有更精简的方法来做到这一点?
Is there a more efficient (in terms of memory foot print) binding to datagrid other than datatable and dataview?
I have a datagrid bound to a dataview which seems to be guzzling a lot of memory . is there a leaner way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
DataTable 是一个相对较重的对象。它保存更改,您可以在其中恢复或提交。支持排序和过滤。使用您需要的公共属性构建一个轻量级类,并将它们传递到构造函数中。然后将这些对象放入 List 中并绑定到 List。 DataGrid 也非常强大而且不轻。如果您只需要简单的只读,那么请使用 GridView ListView。我有一个包含数百万条记录的应用程序,并且一次显示 40 条记录。通过 ListView 虚拟化,您甚至可以呈现 1000 行。
A DataTable is a relatively heavy weight object. It saves changes where you can revert or committ. Supports sorting and filtering. Build a light weight class with the public properties you need and pass them in the contructor. Then put those objects in a List and bind to the List. DataGrid is alsoo powerfull and not light. If you just need simple read only then go with GridView ListView. I have an app with million of records and present records them 40 at a time. With ListView virtualiztion you can even present 1000s of rows.
比列表更好的是 ObservableCollection,它将正确通知 GUI 控件列表中的更改:http://msdn.microsoft.com/en-us/library/ms668604.aspx
And better yet than list is the ObservableCollection which will properly notify the GUI controls of changes in your list: http://msdn.microsoft.com/en-us/library/ms668604.aspx