Overview

from the Artful MySQL Tips List


In VirtualMode a DataGridView can browse a data table of any size. The grid responds almost as fast to a table of millions of rows as it does to a table of a few hundred. Grid cell values are fetched as needed from a clientside cache which keeps just a couple of grid pages of data in memory. When the cache is asked for data it does not have, it retrieves the requested data from the database.
Microsoft provides an IDataRetriever interface for a DataRetriever class, and has published an example implementation that runs against SQL Server. We upgraded the Microsoft example to generalise the code, removed the requirement that the grid be ordered on a primary or unique key, fixed bugs, and made it work with MySQL.The just-in-time data retriever has two classes: DataRetriever, which encapsulates DBMS specifics, and Cache, which is DBMS-agnostic. The class that creates a grid lookup form on the fly, DgvFormJIT, is also DBMS-agnostic.



Return to the Artful MySQL Tips page