KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: On Column Resize Tip
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: November 22, 2016

Starting with 4D v16 the On Column Resize event is triggered continuously as the column continues to be resized. This is beneficial for a more reactive user interface which will continue to trigger the event as a user resizes a column with the mouse, instead of being triggered after the user releases the mouse button.



Below is an example of code that takes advantage of this new feature by reactively adjusting the display format of a column of dates on resize.

//Util_LBColResizeDate
C_POINTER($colObj_p)
C_LONGINT($colW_l)
C_LONGINT($charW_l)

$colObj_p:=Self
$colW_l:=LISTBOX Get column width($colObj_p->)
$charW_l:=7

Case of
    : ($colW_l>=($charW_l*26))
       OBJECT SET FORMAT($colObj_p->;Char(System date long))
   
    : (($colW_l<($charW_l*26)) & ($colW_l>=($charW_l*17)))
       OBJECT SET FORMAT($colObj_p->;Char(System date abbreviated))
   
    : (($colW_l<($charW_l*17)) & ($colW_l>=($charW_l*12)))
       OBJECT SET FORMAT($colObj_p->;Char(Internal date abbreviated))
   
    : (($colW_l<($charW_l*12)) & ($colW_l>=($charW_l*10)))
       OBJECT SET FORMAT($colObj_p->;Char(System date short))
   
    : ($colW_l<($charW_l*10))
       OBJECT SET FORMAT($colObj_p->;Char(Internal date short special))
End case

This utility method uses the fomat based on a character width of 7 and using the largest format that will fit in the width of the column. To use the method, add it to a column object's method under the On Resize event.


Case of
    :(Form event=On Column Resize)
    Util_LBColResizeDate
End case


Below is an example of the display of the column, as the user resizes the column the format will actively change.