How To | Populate a Combo Box or List Box with values using Lua

Learn how to fill a Combo Box or List Box with values using the Lua programming language.

Updated at May 4th, 2023

Your engagement helps us create the content you need. Click here to review this article.

Table of Contents


To populate a Combo Box or List Box, simply set its .Choices to a table of values. For example, if you had a combo box called 'myComboBox', the following script would populate it with 3 strings ("value1", "value2", and "value3"):

local exampleTable = {"value1", "value2", "value3"}
Controls.myComboBox.Choices = exampleTable

Another example is to use dir.get() to get all of the audio file names in a directory and then put them into a Combo Box or List Box. You could do this by creating a table of files and then setting the .Choices of the control to that table as seen below:

directory = "media/Audio/Test"
temp = dir.get(directory)
fileTable = {}

for i,v in ipairs(temp) do
  table.insert(fileTable, directory.."/"

Controls.Files.Choices = fileTable