Introduction
A few years ago a guy by the name of Stefan Hoenig came out with a virtual grid control called Objective Grid which allowed developers to greatly enhance their GUI development where a grid was needed.Later Objective Grid was sold to StingRay. The Grid was an intricate MFC/Visual C++ library that allowed you to do everything from filling a simple cell with data, to adding controls, hiding rows, and many other excel-like features.So basically, if you bought StingRay Grid and figured out how the heck to program it, you could get grid functionality into your application.The problem with the StingRay grid is you may have found yourself weeding through hours of figuring out CellStyles, complex inheritance hierarchies, and various long method names. If it wasn't for the FAQ sheet, you were probably dead in the water. Even tracing through the code with a debugger left you a bit stymied.
Fairly recently, Hoenig formed a new company called SyncFusion which ported the StingRay Grid into .NET.I would say that the port was a vast improvement over the previous version.I was up and running with SyncFusion in a day, and yes, the FAQ sheet is still there.(Admittedly it helps to have used the previous version, StingRay Grid in understanding SyncFusion's world of styles and events).

Figure 1 - Sync Fusion Virtual Grid
Virtual Grid Mode
The SyncFusion Grids virtual mode allows you to map a large piece of data to the Grid. All data displayed inside the grid is drawn using the data you choose to map. The grid allows you to scroll to any piece of your data, even if it is 1,000,000 records long. So how does SyncFusion accomplish this mapping? Anytime the grid needs to redraw a piece of data, it fires an event called QueryCellInfo. This event passes in the row and column necessary to fill and the cell's style. All the user needs to worry about is assigning the cell that is being queried with their data structure. The grid doesn't care where the data comes from, only what the cell style should be when it queries for it. In order to tell the grid how virtual it needs to be (anotherwords how large), the user also needs to trap the events QueryRowCount and QueryColCount (Col stands for column as opposed to say... colonel). Despite the occasional strange method names, the grid is well designed, extremely stable, and as you can see, a snap to get running in virtual mode.
Sample Virtual Grid
In our example we created a sample virtual grid to display addresses. Below is the UML design of our sample Form and associated set of Address objects. Each address contains the data for an address and a string array containing the address data. The Data array is used for filling the grid and for sorting.

Figure 2 - UML Diagram-Reverse engineered using WithClass
The Event Handlers
The event handlers for our simple grid example are shown below. These are the crux of tying your data to the virtual grid. QueryCellInfo checks to make sure that we are not sitting in the column header or row header and then proceeds to populate the queried cell with the value from the addressData cell. The QueryRowCount event handler sets the virtual row count of the grid to the number of elements in the address data structure.

Join the conversation! Your thoughts help the community grow.