KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: When do methods entered in List Box Property List get called?
PRODUCT: 4D | VERSION: 13.3 | PLATFORM: Mac & Win
Published On: August 16, 2013

As pointed out in the Technical Tip Customizing the style and color of rows in a selection based list box project methods can be entered in the List Box Property List to be called to customize Row Styles, Row Font Colors, and Row Background Colors. If the values in method need to be tested and modified it is important to know when these methods are called so values, such as colors, can be set.



It is important to know that these methods are called before the earliest object or form event, On Load. If any values, such as process variables, in these methods need to be set based on values in the records to be presented, these values need to be set before the window is loaded with the Dialog, Modify Selection, or Display Record commands.

Assume the method below will be called to colorize List Box rows based on the numeric value in a field. Based on customer desire the thresholds and colors can be changed dynamically.

$AcctBal_R:=$1

$SRN:=Selected record number([Account])

//======================== Method Actions ==================================

Case of
    : ($AcctBal_R>=Level_1_R)
    $0:=ACCT_Level_1 // green

   Else
     If ($AcctBal_R<Level_2_R)
       Case of
         : ($AcctBal_R>Level_3_R)
           $0:=ACCT_Level_3 // yellow

         : ($AcctBal_R>Level_4_R)
           $0:=ACCT_Level_4 // orange

         Else
           $0:=ACCT_Level_5 // red

       End case
     Else
       // Account balances > Level_2_R and < Level_1_R
       //
       If ($SRN %2 # 0)
         $0:=CLR_OddRow_L // white
       Else
         $0:=CLR_EvenRow_L // pale blue
       End if
   End if
End case


The method below would be called during the process but before the window that will display the List Box is opened to set the values that will be used.

$Table_P:=$1

Case of
   : ($Table_P=(->[Table_1]))
     C_LONGINT(ACCT_Level_1;ACCT_Level_2;ACCT_Level_3;ACCT_Level_4;ACCT_Level_5)
     C_LONGINT(CLR_EvenRow_L;CLR_OddRow_L)
     C_REAL(Level_1_R;Level_2_R;Level_3_R;Level_4_R;Level_5_R)
     ACCT_Level_1:=0xFF00 // green
     ACCT_Level_2:=0 // no coloring
     ACCT_Level_3:=0x00FFDE24 // yellow
     ACCT_Level_4:=0x00FFA600 // orange
     ACCT_Level_5:=0x00FF0000 //Red

     CLR_EvenRow_L:=0x00DEECFE // pale blue
     CLR_OddRow_L:=0x00FFFFFF // white

     Level_1_R:=10000
     Level_2_R:=500
     Level_3_R:=250
     Level_4_R:=50
     Level_5_R:=0

   : ($Table_P=(->[Table_2]))

   Else
     ALERT("Unknow table pointer")

End case


Once the List Box exists on the form the process variables can be changed and a call to REDRAW(myListBoxVar) will update the colors in the list box.