To All
In searching the forum .. I am having difficulty trying to find the code that will be able to change a cell color based on the data in the cell .. I can easily change the entire line based on a value in a row .. but am having difficulties as in this example
column 7 can contain the 3 values 'GREEN', 'YELLOW' or 'RED' .. I want to be able to just color (nROW, 7 ) 'last status' with the correct color .. white\green, black\yellow or white\red. Here is my code where I am struggling .. I am migrating from the standard FWH list box to xbrowse :

In searching the forum .. I am having difficulty trying to find the code that will be able to change a cell color based on the data in the cell .. I can easily change the entire line based on a value in a row .. but am having difficulties as in this example
column 7 can contain the 3 values 'GREEN', 'YELLOW' or 'RED' .. I want to be able to just color (nROW, 7 ) 'last status' with the correct color .. white\green, black\yellow or white\red. Here is my code where I am struggling .. I am migrating from the standard FWH list box to xbrowse :
nWd := GetSysMetrics(0) * .70 //.60
nHt := GetSysMetrics(1) * .85
DEFINE ICON oICO RESOURCE "SCANNER"
DEFINE WINDOW oWnd1 ;
FROM 1,1 to nHT, nWD PIXEL ;
TITLE cTITLE ;
MENU ProjMenu(oRsProj, oWndMdi) ;
ICON oICO ;
NOMINIMIZE ;
NOZOOM ;
MDICHILD
@ 0, 0 xBROWSE oBrw of oWnd1 ;
RECORDSET oRsProj ;
COLUMNS "PROJNAME", ;
"descrip", ;
"reporting", ;
"projmgr", ;
"start_date", ;
"end_date", ;
"est_budget", ;
"frequency", ;
"row_color" ;
COLSIZES 130,183,30,85,85,85,85,90,90 ;
HEADERS "Proj Name", ;
"Description", ;
"CRpt", ;
"ProjMgr", ;
"Orig Start Dt", ;
"Orig End Date", ;
"Orig Est Budget", ;
"Frequency", ;
"Last Status" ;
AUTOSORT AUTOCOLS LINES CELL
oWnd1:oClient := oBrw
oBrw:bLDblClick := { |nRow,nCol | _ProjView( "V", oRsProj,"","" ) }
* oBrw:bClrStd := {|| {CLR_BLACK, if( oRsProj:Fields("active"):Value = 'Y', RGB(179,203,204), CLR_WHITE ) } }
AEval( oBrw:aCols, { |o| SetClrBlock( o, oRsProj ) } )
// paint the row colors active and status column //
* obrw:nClrText := { |nCOL| SelColorF( nCOL, oRsProj:Fields("row_color"):Value, oRsProj:Fields("active"):Value, "F" ) }
* oBrw:nClrPane := { |nCOL| SelColorB( nCOL, oRsProj:Fields("row_color"):Value, oRsProj:Fields("active"):Value, "B" ) }
// oBrw:nClrForeFocus = { |nCOL| SelColorH( nCOL, oRsProj:Fields("row_color"):Value, oRsProj:Fields("active"):Value, "F" ) }
* oBrw:nClrBackFocus := { |nCOL| SelColorH( nCOL, oRsProj:Fields("row_color"):Value, oRsProj:Fields("active"):Value, "B" ) }
* oBrw:aCols[ 9]:bClrStd := {|| { IF( ALLTRIM(oRsProj:Fields("row_color"):Value) = 'YELLOW', CLR_YELLOW, CLR_HGREEN), CLR_WHITE } }
* oBrw:bClrSel:={ || { nTextClr, nBackClr } }
oBrw:CreateFromCode() // recommendation from daniel
ACTIVATE WINDOW oWND1 ;
ON INIT( IF( lFROMLINK = .T., (_ProjView( "V", oRsProj,"", lFROMLINK )), ),( oBrw:SetFocus(), .F. ));
VALID ( IIF( !lOK, _ProjClose(.T.), .F. ))
RETURN( .T. )
//------------------------
static function SetClrBlock( oCol, oRsProj )
*local nCol := oCol:nCreationOrder
*local oBrw := oCol:oBrw
LOCAL cSTATUS,cACTIVE
IF EMPTY(oRsProj:Fields("row_color"):Value)
cSTATUS := "NO STATUS"
ELSE
cSTATUS := alltrim( oRsProj:Fields("row_color"):Value)
ENDIF
IF EMPTY(oRsProj:Fields("active"):Value)
cACTIVE := "*"
ELSE
cACTIVE := oRsProj:Fields("active"):Value
ENDIF
*oBrw:aCols[ 9]:bClrStd := {|| { IF( ALLTRIM(oRsProj:Fields("row_color"):Value) = 'YELLOW', CLR_YELLOW, CLR_HGREEN), CLR_WHITE } }
DO CASE
*CASE nCOL < 9
CASE cSTATUS = "YELLOW"
oBrw:aCols[ 9]:bClrStd := {|| { CLR_WHITE, CLR_YELLOW } }
* oBrow:bClrStd := {|| {CLR_BLACK, if( cACTIVE = 'Y', RGB(179,203,204), CLR_WHITE ) } }
/*
IF cACTIVE = 'N'
oCOL:bClrStd := { || { CLR_WHITE, RGB(179,203,204)}}
* nCOLOR := RGB(179,203,204) // light blue
ELSE
oCOL:bClrStd := { || { CLR_BLACK, CLR_WHITE }}
ENDIF
*/
*CASE nCOL = 9 .and. cSTATUS = "GREEN"
* oCOL:bClrStd := { || { CLR_WHITE, CLR_HGREEN }}
*oBrw:aCols[ 7]:bClrStd := {|| { IIF( oRsPro:Fields("PRO_PRE"):Value > 10000, CLR_HRED, CLR_HBLUE), CLR_GRAY } }
*CASE nCOL = 9 .and. cSTATUS = "YELLOW"
* oCOL:bClrStd := { || { CLR_WHITE, CLR_YELLOW }}
*CASE nCOL = 9 .and. cSTATUS = "RED"
* oCOL:bClrStd := { || { CLR_WHITE, CLR_HRED }}
ENDCASE
return nil
//-----------------------------------------------
Static Func SelColorB( nCOL, cCOLOR, cACTIVE, cTYPE )
LOCAL nCOLOR := CLR_WHITE
// background for all cells
msginfo( ncol )
DO CASE
CASE nCOL < 9
IF cACTIVE = 'Y'
nCOLOR := CLR_WHITE
ELSE
nCOLOR := RGB(179,203,204) // light blue
ENDIF
CASE nCOL = 9 .and. cCOLOR = "GREEN" .and. cTYPE = "B"
nCOLOR := CLR_HGREEN
CASE nCOL = 9 .and. cCOLOR = "YELLOW".and. cTYPE = "B"
nCOLOR := CLR_YELLOW
CASE nCOL = 9 .and. cCOLOR = "RED" .and. cTYPE = "B"
nCOLOR := CLR_HRED
ENDCASE
RETURN( nCOLOR )
//--------------------
Static Func SelColorF( nCOL, cCOLOR, cACTIVE, cTYPE )
LOCAL nCOLOR := CLR_BLACK
// forground for all cells
IF EMPTY(nCOL) .or. nCOL = NIL
nCOL := 8
ENDIF
DO CASE
CASE nCOL < 9
IF cACTIVE = 'Y'
nCOLOR := CLR_BLACK
ELSE
nCOLOR := CLR_BLACK // RGB(255,0,0 ) // red
ENDIF
CASE nCOL = 9 .and. cCOLOR = "GREEN" .and. cTYPE = "F"
nCOLOR := CLR_BLACK
CASE nCOL = 9 .and. cCOLOR = "YELLOW".and. cTYPE = "F"
nCOLOR := CLR_BLACK
CASE nCOL = 9 .and. cCOLOR = "RED" .and. cTYPE = "F"
nCOLOR := CLR_BLACK
ENDCASE
RETURN( nCOLOR )
//-----------------------------------------------
Static Func SelColorH( nCOL, cCOLOR, cACTIVE, cTYPE )
// background for hi-lite bar
LOCAL nCOLOR := CLR_HGRAY
msginfo( ncol )
msginfo( "selcolorh")
return(ncolor )
DO CASE
CASE nCOL < 9
IF cACTIVE = 'Y'
nCOLOR := rgb( 122,122,122 ) //CLR_HGRAY
ELSE
nCOLOR := RGB(179,203,204) // light blue
ENDIF
CASE nCOL = 9 .and. cCOLOR = "GREEN" .and. cTYPE = "B"
nCOLOR := CLR_HGREEN
CASE nCOL = 9 .and. cCOLOR = "YELLOW".and. cTYPE = "B"
nCOLOR := CLR_YELLOW
CASE nCOL = 9 .and. cCOLOR = "RED" .and. cTYPE = "B"
nCOLOR := CLR_HRED
ENDCASE
RETURN( nCOLOR )