4D View Pro – Variable Row Height in Listbox

Displaying a list where the line height would exactly fit the content is a very common need. 4D View Pro is including a new feature so that you can now control the height of each row independently in a listbox to make it fit to its content. To know more about 4D View Pro, check out this blog post.

There are actually now two ways to define the row height in a listbox:

  • using new dedicated commands
  • using a new control array

Using new commands

The new commands LISTBOX SET ROW HEIGHT and LISTBOX Get row height allow to set and get the height of each row individually.

If you execute this code:

LISTBOX SET ROW HEIGHT(*;"listboxname";1;184) //Pellentesque
LISTBOX SET ROW HEIGHT(*;"listboxname";2;41) //Vestibulumn
LISTBOX SET ROW HEIGHT(*;"listboxname";3;86) //Suspendisse

You get the following result:

Variable row height in 4D View Pro Listbox

 

Using a height control array

You can use this property to specify the name of the row height array you want to associate with the listbox.

Row height settings in 4D property list

For example, if you write:

//current unit is lines
ARRAY LONGINT(<>RowHeightArray;20)
<>RowHeightArray{5}:=3

The fifth row of the listbox will have a height of three lines, while every other row will keep their default height.

You can also associate the height control array by programming. The LISTBOX SET ARRAY and LISTBOX Get array commands now accept a Listbox row height array selector allowing you to define the row height control array via programming.

LISTBOX SET ARRAY ( {* ;} object ; Listbox row height array ; <>RowHeightArray )
<>RowHeightArray:=LISTBOX Get array ( {* ;} object ; Listbox row height array )

You want to try it by yourself ? Just download the following example!

Database Example

For more details, please refer to the following articles in the 4D v16 documentation:

Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.