KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: ListBox Row Height Control Priority
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: March 6, 2017

When controling listbox row height there are two approaches. One is globally setting all rows to a height by modifying the global height value. This can be set in the properties list or through code by using the command LISTBOX SET ROWS HEIGHT.


The second approach is to set the heights on an individual basis row by row. This is set by assigning the value to a longint array assigned to the row height array property, and by code by modifying the array dirrectly or using the command LISTBOX SET ROW HEIGHT.

With the row height array assigned as rowH_al the following two examples perform the same task.

LISTBOX SET ROW HEIGHT(*;"List Box";2;1)

rowH_al{2}:=1

When using both, the individual row heights takes precedence.
For example...
LISTBOX SET ROW HEIGHT(*;"List Box";2;1)
LISTBOX SET ROWS HEIGHT(*;"List Box";2;lk lines)
LISTBOX SET ROWS HEIGHT(*;"List Box";4;lk lines)

...will result in the listbox having the second row of a height 2 and the rest with a height of 4 as shown


This is because the row height array values will be applied and only if the value is 0, the global height value will be applied. The rows can be reset on an individual basis using the methods above to set the value back to 0. There are two easy ways to reset all of the rows and associate them with the global height.
Redeclare the variable:
ARRAY LONGINT(rowH_al;0)

Change the units for calculating the row height:
C_LONGINT($rowH_l)
$rowH_l:=LISTBOX Get rows height(*;"List Box";lk lines)
LISTBOX SET ROWS HEIGHT(*;"List Box";1;lk pixels)
LISTBOX SET ROWS HEIGHT(*;"List Box";$rowH_l;lk pixels)

For Example setting the array element back to 0 will allow the global value to be applied.
LISTBOX SET ROW HEIGHT(*;"List Box";2;1)
LISTBOX SET ROWS HEIGHT(*;"List Box";4;lk lines)
LISTBOX SET ROW HEIGHT(*;"List Box";2;0)
LISTBOX SET ROWS HEIGHT(*;"List Box";2;lk lines)