Dynamically Format Grid Columns

File: SAMPLES\SOLUTION\CONTROLS\GRID\DYNGRID.SCX

This sample illustrates setting the DynamicForeColor and DynamicBackColor properties of grid columns.

The code of interest in this sample is associated with the InteractiveChange event of the drop-down list cboFormat.

First, the code clears the dynamic fore and back color settings:

oGrd.SetAll("dynamicbackcolor", "", "Column")
oGrd.SetAll("dynamicforecolor", "", "Column")

Then, code in a CASE statement sets the new DynamicForeColor or DynamicBackColor properties. For example, the following line of code displays discontinued items with a gray ForeColor.

oGrd.SetAll("dynamicforecolor", ;
   "IIF(discontinu, RGB(192,192,192), RGB(0,0,0))", "Column")

Discontinu is a logical field in the Products table.