Display a message-box from within OnValidateCell

The easiest way is to override OnValidateCell and call SetWarningText. This technique is illustrated in the first example:

// validate input
BOOL CDerGrid::OnValidateCell(ROWCOL nRow, ROWCOL nCol)
{
   CString s;
   CGXControl* pControl = GetControl(nRow, nCol);
   pControl->GetCurrentText(s);
   if (!s.IsEmpty( ))
   {
      if (_ttoi(s) < 1 || _ttoi(s) > 100)
      {
         SetWarningText (_T("Please enter a value between 1 and 100!"));
         return FALSE;
      }
      return TRUE;
   }
   return CGXGridView::OnValidateCell(nRow, nCol);
}

It is also possible to display a message box with AfxMessageBox. See "Validation" in the "Advanced Question" section.