MATLAB: Adding multiple items to a list box in app designer

appdesignerlistboxMATLAB

Hi,
I am trying to add multiple items to the list box. However, it only displays the first item. The screen shot of the result and the code are below. I am in 2019a.
Thank you in advance for any help! 🙂
app.TrainClassListBox.Items={'30','40'};
app.TrainClassListBox.Items(3)={'60'};

Best Answer

Your code adds the new field. Are you getting an error message, or is it just not displaying? Perhaps look into what is entered in app.ListBox.ItemsData? This controls what is displayed in the ListBox. It seems like it is set to 1. Try setting it back to the default (empty brackets).
app.TrainClassListBox.ItemsData=[];