xBrowse Color a Column using HB_DECODE ( Rao )

xBrowse Color a Column using HB_DECODE ( Rao )

Postby Rick Lipkin » Sat Jun 27, 2020 6:05 pm

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  Expand view  RUN

   // 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
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Color a Column using HB_DECODE ( Rao )

Postby nageswaragunupudi » Mon Jun 29, 2020 4:22 pm

Please use FW_DECODE() instead of HB_DECODE()
Code: Select all  Expand view  RUN
  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
nageswaragunupudi
 
Posts: 10651
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse Color a Column using HB_DECODE ( Rao )

Postby Rick Lipkin » Mon Jun 29, 2020 6:13 pm

Rao

Thank you .. your code worked perfectly ..

Thank You VERY Much!

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 63 guests