xBrowse Color a Column using HB_DECODE ( Rao )

Post Reply
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

xBrowse Color a Column using HB_DECODE ( Rao )

Post by Rick Lipkin »

Rao

I am using some code from an old working program using xBrowse .. I have a defined column "Status" which maps back to a recordset field named FANSWER. Here is the code .. I want to color the "Status" ( oRsTrav:Fields("FANSWER"):Value ) column with either Red, Green or Yellow based on three possibilities ..

Code: Select all

   // EMployee browse -----------------------
   REDEFINE xBROWSE oLbxB             ;
         RECORDSET oRsTrav            ;
         COLUMNS "PERSNO",            ;
                 "EMPLOYEE",          ;
                 "EVENT",             ;
                 "LOCATION",          ;
                 "SPONSOR",           ;
                 "FANSWER",           ;
                 "GRANDTOT  "        ;
         COLSIZES 85,135,135,135,135,85,100    ;
         PICTURE  "","", "", "", "", "", "999,999.99";
         HEADERS "Persno",            ;
                 "Employee Name",     ;
                 "Event Name",        ;
                 "Location",          ;
                 "Sponsor",           ;
                 "Status",            ;
                 "Total"              ;
         ID 132 of oGrps  ;
         AUTOCOLS FOOTERS LINES CELL

*   oLbxB:nMarqueeStyle := MARQSTYLE_HIGHLROW
   oLbxB:lRecordSelector := .f.

   oLbxB:lFooter   := .t.
   oCol1           := oLbxB:aCols[ 1 ]
   oCol1:bFooter   := { || Ltrim( Str( oLbxB:KeyNo() ) ) + " / " + LTrim( Str( oLbxB:KeyCount() ) ) }
   oLbxB:bChange   := { || oCol1:RefreshFooter() }

   oLbxB:bClrGrad := { | lInvert | If( ! lInvert, ;
                    { { 0.50, 15790320, 15790320 }, ;
                    { 0.50,   15790320, 15790320 } }, ;
                    { { 0.50, 15790320, 15790320 }, ;
                    { 0.50,   15790320, 15790320 } } ) }

   if(oRsTrav:eof, ,oLbxB:oCol( "Status" ):bClrStd := ;                   // <---   here
                { || HB_Decode( AllTrim( oLbxB:oCol("Status"):value ), ;
                      "APPROVED",    { CLR_BLACK, CLR_HGREEN }, ;
                      "OPEN",        { CLR_BLACK, CLR_YELLOW }, ;
                      "REJECTED",    { CLR_WHITE, CLR_HRED } ) } )
 
Why does this code not work ?? .. or perhaps you can suggest a better way of coding this ..

Thanks
Rick Lipkin
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: xBrowse Color a Column using HB_DECODE ( Rao )

Post by nageswaragunupudi »

Please use FW_DECODE() instead of HB_DECODE()

Code: Select all

   oLbxB:oCol( "Status" ):bClrStd := ;                   // <---   here
                { || FW_Decode( UPPER( AllTrim( oLbxB:oCol("Status"):value ) ), ;
                      "APPROVED",    { CLR_BLACK, CLR_HGREEN }, ;
                      "OPEN",        { CLR_BLACK, CLR_YELLOW }, ;
                      "REJECTED",    { CLR_WHITE, CLR_HRED }, ;
                      { CLR_BLACK, CLR_WHITE}  ) }  // last is default 
 
Note: eof check is not necessary.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Color a Column using HB_DECODE ( Rao )

Post by Rick Lipkin »

Rao

Thank you .. your code worked perfectly ..

Thank You VERY Much!

Rick Lipkin
Post Reply