How can I implement some caching in a virtual grid?

If you want to implement some kind of caching, you might override the OnDraw method.  There, you could determine the top row with

   nFirstRow = GetTopRow();

and the bottom row of the grid with

   nLastRow = CalcBottomRowFromRect(GetGridRect());

You could then check this rows whether they fit into your current cached page and load/unload the rows from your cache appropriately.