[Closed] Maxscript listBox refresh
Hi there,
I currently have a script that creates a list box that gets populated with some directory names once I select a project from another dropdown selection list in the same rollout. Currently each time I change the selection in the dropdown it adds the associated directory names to the existing contests of the listBox. I would really like the list box to be reset/cleared each time I change the sleection in the dropdown. I’ve tried using Fileslbx1.items = #() to flush listBox item array but I can’t seem to use that from within the dropdown selection function successfully.
Any help much appreciated.
Kind Regards,
Nathan.
It is a good idea to show some of your code when you have a problem with it
try (destroydialog X ) catch ()
rollout X "" (
local items = #( #("1", "2", "3"), #("4", "5", "6"), #("7", "8", "9") )
dropdownlist dd items:#( "a", "b", "c" )
listbox lb items:items[ 1 ] height:3
on dd selected index do lb.items = items[ index ]
)
createDialog X
This is exactly what I need it to do! Thankyou Serejah.
My code is still embarrassingly beginner-y but I will send where I’m at next time.
Kind Regards,
Nathan.
Am I able to update the local items to new values easily? Is it just a case of accessing the items via array? like items[3]? Sorry I am not near a max license at the moment.
Kind Regards,
Nathan.
With your help I have it sorted! Thanks again.
destroyDialog x
rollout x “Untitled” width:197 height:275
(
listbox 'lb' "Files/Folders" pos:[23,55] width:112 height:8 align:#left
dropdownList 'ddl2' "DropDownList" pos:[27,15] width:102 height:40 items:#("C drive:", "D drive:") align:#left
on ddl2 selected index do
(
temp_gather =#()
temp_gather[1] = getDirectories "C:\\*"
temp_gather[2] = getDirectories "D:\\*"
lb.items = temp_gather[index]
)
)
createDialog x