How to specify the number of rows and columns in the grid?

Call SetRowCount and SetColCount.

Example:

   // specify the dimension of the grid
   SetRowCount(nRows);
   SetColCount(nCols);

The row and column count can be changed again anytime at runtime.