Can I outline cells depending on their value?

The following  example changes only the SetInterior( ) style of a cell, which can be one of

  • gray: value not used (cell will be made read-only, another change)

  • white: value is not yet set

  • green: value is set, interacting values result in feasible set

  • red: value is set, interacting values result in infeasible set

All other properties of the cell remain unchanged. 

BOOL CSampleView::GetStyleRowCol(ROWCOL nRow, ROWCOL nCol, CGXStyle& style, GXModifyType mt, int nType)
{
   CMyGridView::GetStyleRowCol(nRow, nCol, style, mt, nType);
   if (nRow > 0 && nCol > 0)
   {
      CString s = style.GetValueRef( );
      if (criteria_1)
         // disable the cell - user can't click into it anymore
         style.SetEnabled(FALSE).SetInterior(RGB(192,192,192));
      else if (s.IsEmpty( ))
      // make white if empty
         style.SetInterior(RGB(255,255,255));
      else if (invalid s)
      // make red if invalid
         syle.SezInterior(RGB(255,0,0));
      else
      // make green if valid
         style.SetInterior(RGB(0,255,0));
   }
   return TRUE;
}

This would also be a good example for using base styles. See “What is a base style” in the section "Overview".