0

I have a rather interesting problem to solve, and not sure how would I approach it the best way.

Given such a interface

public interface IDataCursor
{
    bool Eof();
    bool Next();
    bool Prev();
    bool First();
    bool Last();

    int GetColumnCount();
    object GetValue(int columnIndex); // return value for a given column from current cursor position
}

which points to a LARGE data structure, and which I need to display in a grid. All of virtual modes do require the Total number of records to be known. This doesn't work on my case. I can only navigate back/forth.

Does anyone know of some kind of DataSource implementation that would implement a similar interface?

None of the existing free or commercial libraries do offer such a possibility, all of them require the Total number of rows.

I tried to calculate the number of visible records for the DataGtidView then somehow navigate through dataset and update the content of the underlying datasource, but data won't display pretty reliable.

Looking for advises, thank you.

Eugen
  • 2,934
  • 2
  • 26
  • 47
  • 1
    “I need to display in a grid” and “I can only navigate back/forth” contradict each other; at least one of those statements is false. Which one? Or are they both false? – Dour High Arch May 13 '15 at 18:51
  • no, they both are true. Let's say grid has 15 rows visible rows, then I should navigate position to first record using.First() then 15 times call .Next() check for Eof() and display data for each column. – Eugen May 13 '15 at 19:12
  • 1
    Then your first statement is false. As you have discovered, DataGridView requires a length so it can show a scrollbar and thumb. Use a [pager](http://stackoverflow.com/questions/2825771/) or some other control that does not require a length. – Dour High Arch May 13 '15 at 19:40
  • that's the whole idea. to either find another control or to use somehow the grid without knowing the total number of records. – Eugen May 13 '15 at 19:45
  • Yes, it's possible to put this in a grid but it would be unbelievably slow. There is no row indexer. And traversing the whole data set constantly over a "LARGE" data structure just to find specific rows would kill performance. – Zer0 May 13 '15 at 19:59
  • Move your mouse pointer over the word “pager” in my comment above and click. – Dour High Arch May 13 '15 at 20:23
  • @Dour High Arch: the problem with the pager is that it loads all data in memory anyway. Imagine user pressed Ctrl-End which means go to last record, using pager I'll have to read all records and put into the underlying list. I tried that, is VERY slow, it takes like 5 min for 5 million records. But instead I could just position the cursor to .Last position and then read last N visible records. using .Prev method. This happens instantly. – Eugen May 13 '15 at 22:34
  • 1
    Pagers only load the data in a single page, which can be as few records as you wish; when you go to the next page the previous page is discarded. If you can go to the last record, then do so and load the previous number of records you want to show. – Dour High Arch May 13 '15 at 23:41

1 Answers1

0

Perform query select count(*) from table_name where my_where_cluase; and then use the same my_where_cluase while populating the Grid