4D Blog

Home Product Ease your developer’s life with list boxes

Ease your developer’s life with list boxes

January 31, 2020

Product
Our main objective is to make developers’ lives easier, day after day, and list boxes are one 4D’s most used and powerful form objects that serve this purpose. We all know that list boxes trigger many events, that’s why in 4D v18 R2 we’ve enhanced the Form event command to return even more information when list box events are triggered.
 
Want to let go of your old tricky code for guessing which row, column, or header you clicked or put your mouse on? Let us show you a smoother and smarter way to do it!

HDI: Examples to work easily with Listbox events

Depending on the event, additional relevant properties are now returned by the Form event command.
 
Let’s check out some examples.

On header click event

The header object’s name, column object’s name and column number are now returned by the Form event command.
Here’s an example of the object returned when an On Header Click event is triggered/

{"headerName":"headerLastname", // New property - Header object name
"columnName":"lastname", // New property - Column object name
"column":2,   // New property - Column number
"code":42,
"description":"On Header Click",
"objectName":"EmployeesLB"}

For example, if you set a column object name with a real attribute name of a dataclass (e.g., lastname):

 

 

When clicking on the header of the column displaying the employees’ last name, we sort the column on the lastname and firstname attributes:

Form.event:=FORM Event
Case of
: (Form event code=On Header Click)
 if (Form.event.columnName="lastname")
  Form.employees:=Form.employees.orderBy(Form.event.columnName+", firstname")
 End if
End case
 

On DISPLAY DETAILS event

When the On Display Details event is triggered, additional relevant properties (e.g., isRowSelected) are now returned by the Form event command. This can be helpful to manage the appearance of a list box’s lines.
 
Below is an example of a method (setColor) set in the Meta info expression property of a list box:
 
blank
 
The setColor method:
C_OBJECT($event;$0;$meta)
$event:=FORM Event
$meta:=New object
Case of
: ($event.code=On Display Detail)
 If ($event.isRowSelected) //set color when row is selected
  $meta.fill:="lightblue"
 End if
End case
$0:=$meta
 

And here’s how the list box looks when rows are selected:

blank
 

On mouse move EVENT

Another frequently used event is the On Mouse Move event. Below are examples of objects returned by the Form event command when it’s triggered.

You immediately get useful properties to locate where you put your mouse!

The mouse hovers over a header

Form event command returns:

{"area":"header", // The mouse is on a header
"areaName":"headerLastname", // Header object name
"column":2, //  Column number
"columnName":"lastname", // Colmun object name
"code":37,
"description":"On Mouse Move",
"objectName":"EmployeesLB"}

 

The mouse hovers Over a cell

Form event command returns:

{"area":"cell", // The mouse is on a cell
"column":1, //  Column number
"row":2, //  Row number
"columnName":"firstname", // Colmun object name
"code":37,
"description":"On Mouse Move",
"objectName":"EmployeesLB"}
 
There are so many list box events that a single blog post is not enough to cover them all, so be sure to check the documentation to find extensive information about each event and download the HDI to learn more!
 
 
 
 
Discuss

Tags Event, Listbox, Programming, v18 R2, v19

Latest related posts

  • November 14, 2025

    Event Report in 4D Qodly Pro: See Every Interactions at a Glance

  • November 14, 2025

    4D Qodly Pro: Page Zoom Controls

  • November 13, 2025

    macOS Tahoe, Windows 11, which operating systems for 4D 20 and 21?

Avatar
Marie-Sophie Landrieu-Yvert
- Product Owner - Marie-Sophie Landrieu-Yvert joined the 4D Product team as a Product Owner in 2017. In this role, she is responsible for writing user stories and translating them into functional specifications. She also ensures that the delivered feature implementation meets the customer's needs. Marie-Sophie graduated from the engineering school ESIGELEC and began her career as an engineer at IBM in 1995. She took part in various projects (maintenance and development projects) and worked as a COBOL developer. She then moved on to work as a UML designer and Java developer. More recently, her main responsibilities included analyzing and writing functional requirements, and coordinating business and development teams.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy