FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xbrowse row colours
Posts: 38
Joined: Fri Apr 22, 2016 10:19 PM
xbrowse row colours
Posted: Mon Mar 02, 2020 10:37 PM
Dear community,

I have tried to give a row another colour and it worked with this code.

oBrw:bClrStd := { || If( (cust->resstatus = "###Cancelled" .and. cust->guarancode = " "), { CLR_WHITE, CLR_RED }, { CLR_BLACK,CLR_WHITE } ) } //@IA 2020030

How can I integrate another colour for another request?
/* oBrw:bClrStd := { || If( ((cust->resstatus = "Waitlisted" .or. cust->resstatus = "Reserved" ).and. cust->guarancode = " "), ;
{ CLR_WHITE, CLR_GREEN }, { CLR_BLACK,CLR_WHITE } ) } //@IA 20200301*/

Do I have to use elseif in the oBrw:bClrStd?

If( (cust->resstatus = "###Cancelled" .and. cust->guarancode = " ") --> backgroundcolur should be red
If( ((cust->resstatus = "Waitlisted" .or. cust->resstatus = "Reserved" ).and. cust->guarancode = " ") --> backgroundcolur should be green

Thank you in advance and kind regards
Iris
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: xbrowse row colours
Posted: Mon Mar 02, 2020 11:26 PM
Iris, if the condition to set the colors is very complicated, I advise you to use a function that returns the corresponding color array

Code (fw): Select all Collapse
oBrw:bClrStd := { || MyColors( oBrw ) }
.../...

Function MyColors( oBrw )
    local aColors := { , }

   If (cust->resstatus = "###Cancelled" .and. cust->guarancode = " ")
       aColors := { CLR_WHITE, CLR_RED }
   else
      if <other condition>
          aColors := { ....,  ..... }    etc.
      else
         aColors  := { CLR_BLACK,CLR_WHITE }
      endif
   endif
   .../...


Return aColors
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 38
Joined: Fri Apr 22, 2016 10:19 PM
Re: xbrowse row colours
Posted: Tue Mar 03, 2020 06:11 AM

Thank you!

Posts: 38
Joined: Fri Apr 22, 2016 10:19 PM
Re: xbrowse row colours
Posted: Tue Mar 03, 2020 08:55 PM

I have just tried it, It worked perfectly, thank you, Cristobal!

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: xbrowse row colours
Posted: Wed Mar 04, 2020 02:11 AM
Dear Iris, another way is to define the codeblock like this:


Extended literal code block.
Syntax
<| [<params,...>] | <programcode> >

Code (fw): Select all Collapse
oBrw:bClrStd := <||
    local aColors := { , }

   If (cust->resstatus = "###Cancelled" .and. cust->guarancode = " ")
       aColors := { CLR_WHITE, CLR_RED }
   else
      if <other condition>
          aColors := { ....,  ..... }    etc.
      else
         aColors  := { CLR_BLACK,CLR_WHITE }
      endif
   endif
   .../...
Return aColors
>
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces

Continue the discussion