How should I fill the grid with values?

SetValueRange and SetStyleRange lets you change cell values and formatting. It is recommended that you call LockUpdate(TRUE) before you do several SetValueRange() calls. Upon initialization of the grid you should also turn off undo creation.

Example:

   // turn off undo creation, prevent updating the grid
GetParam()->EnableUndo(FALSE);
   BOOL bOldLock = LockUpdate(TRUE);
   // specify the dimension of the grid
   SetRowCount(nRows);
   SetColCount(nCols);
   // fill cell values
   for (...)
   {
      CString str;
      double d;
      CGXStyle style;
      
      SetValueRange(CGXRange(nRow, 1), str);   // string
      SetValueRange(CGXRange(nRow, 2), d);   // number
      // you can also use SetStyleRange to apply values
      SetStyleRange(CGXRange(nRow, 3), style.SetValue(str));
      // apply a value together with text color
      SetStyleRange(CGXRange(nRow, 4), style
.SetValue(str)
.SetTextColor(RGB(255, 0, 0)
);
   }
   // enable updating the grid and undo creation
   LockUpdate(bOldLock);
   GetParam()->EnableUndo(TRUE);
   // Redraw the grid
   Redraw();

See also the 1stGrid tutorial in ogguide.doc.