Article ID: 132549
Article Last Modified on 8/12/1999
DynamicForeColor DynamicBackColor DynamicFontName DynamicFontSize DynamicFontBold DynamicFontItalic DynamicFontStrikethru DynamicUnderline DynamicAlignment DynamicCurrentControl
** Begin code example
OPEN DATABASE c:\vfp\samples\mainsamp\data\tastrade
#include FOXPRO.h && used for color constants.
PUBLIC otheForm && keep form live after the program is done
otheForm = CREATEOBJECT("theForm") && make the form
otheForm.SHOW && show the form
DEFINE CLASS theForm AS FORM && class definition for the form
SCALEMODE = 0
ADD OBJECT "testgrid" AS mygrid && add the grid to the form
PROCEDURE INIT
THISFORM.CAPTION = "Grid with conditional color in rows"
THISFORM.WIDTH = 100
THISFORM.BACKCOLOR = RGB(192,192,192)
ENDPROC
PROCEDURE DESTROY
SET DATABASE TO tastrade
CLOSE DATA
RELEASE thisform
ENDPROC
ENDDEFINE
DEFINE CLASS mygrid AS GRID && class definition for the grid
COLUMNCOUNT= 3
SCROLLBARS = 3
RECORDSOURCETYPE = 0 && alias
RECORDSOURCE = "Customer"
WIDTH = 83
TOP = 1
LEFT = 7
PROCEDURE INIT && use the init procedure to set
&& appropriate column properties
WITH THIS.column1
.header1.CAPTION = "Customer ID"
.WIDTH = 15
.CONTROLSOURCE = "customer.customer_id"
ENDWITH
WITH THIS.column2
.header1.CAPTION = "Company Name"
.WIDTH = 25
.CONTROLSOURCE = "customer.company_name"
ENDWITH
WITH THIS.column3
.WIDTH = 10
.header1.CAPTION = "Region"
.CONTROLSOURCE = "customer.region"
ENDWITH
** The following two lines of code determine the conditional
** row color for the grid:
foreexpr = 'IIF(ALLTRIM(customer.region) == "WA",' + ;
LTRIM(STR(COLOR_BLUE)) + ',' + LTRIM(STR(COLOR_BLACK)) +')'
THIS.SETALL("DynamicForeColor",foreexpr,"Column")
ENDPROC
ENDDEFINE
** End code example
Additional query words: VFoxWin
Keywords: KB132549