将大量数据加载到datagrid的最佳方法

时间:2022-12-16 14:45:29

I am trying to load a lot of data into a datagrid which as you would expect takes a long time to load up. This is due to the face that I am loading data from a COM object which I have wrapped up into .NET object with a custom enumerator.

我正在尝试将大量数据加载到数据网格中,正如您所期望的那样需要很长时间才能加载。这是因为我正在从一个COM对象加载数据,我已经用自定义枚举器将其包装到.NET对象中。

I have looked into virtual loading the datagrid and it works alright but I was wondering if there was a better way of doing the same thing.

我已经研究了虚拟加载数据网格并且它工作正常,但我想知道是否有更好的方法来做同样的事情。

What I am after is a datagrid that shows a scroll bar for the whole amount of data but only loads the data for the first say 50 rows then after you scroll it loads the next 50 or so.

我所追求的是一个数据网格,它显示了整个数据量的滚动条,但只加载了第一个说50行的数据,然后滚动后加载下一个50左右。

Does anyone know if this is possible, or if there is a control available that does this automatically?

有没有人知道这是否可行,或者是否有可用的控件自动执行此操作?

2 个解决方案

#1


Is it possible to load only a part of the data from the COM object? If so, load for example 100 rows, and save the rowcount. Then in the scroll event of the grid, use the FirstDisplayedScrollingRowIndex property to see if you are getting close to 100, and load some more rows, and increment the rowcount.

是否可以仅从COM对象加载一部分数据?如果是,则加载例如100行,并保存rowcount。然后在网格的滚动事件中,使用FirstDisplayedScrollingRowIndex属性来查看是否接近100,并加载更多行,并增加rowcount。

This does not however show a scrollbar for all loadable rows.

但是,这不会显示所有可加载行的滚动条。

#2


Check out Telerik datagrid controls.

查看Telerik数据网格控件。

#1


Is it possible to load only a part of the data from the COM object? If so, load for example 100 rows, and save the rowcount. Then in the scroll event of the grid, use the FirstDisplayedScrollingRowIndex property to see if you are getting close to 100, and load some more rows, and increment the rowcount.

是否可以仅从COM对象加载一部分数据?如果是,则加载例如100行,并保存rowcount。然后在网格的滚动事件中,使用FirstDisplayedScrollingRowIndex属性来查看是否接近100,并加载更多行,并增加rowcount。

This does not however show a scrollbar for all loadable rows.

但是,这不会显示所有可加载行的滚动条。

#2


Check out Telerik datagrid controls.

查看Telerik数据网格控件。