KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to use Selected list items to obtain reference number of a tab control item
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: May 17, 2021

When using a tab control object, there are a few ways to populate its labels. An object or an array can be created with tab item values, and linked to the tab control variable or expression. Another way is to assign default values from the property list. A third way is to create a list in the Lists editor and link it to the tab control object as a choice list.

By linking the tab control to a choice list, the reference number of the list item can be obtained whenever a user clicks on a tab item. This can be accomplished using the command Selected list items and minimal set up of the tab control. First, make sure the “Variable or Expression” of the tab control is blank. Then, “Expression Type” should be set to Numeric.



Finally, in the object method of the tab control, call the following in an On Clicked event case:

$sel:=Selected list items(*;OBJECT Get name(Object current);*)

$sel will then return the reference number of the list item corresponding to the tab item that the user clicked on. Note that if the final asterisk argument is omitted, $sel will return the position number instead.