How to dynamically add new row component in ListBox?

Hi JUCE masterminds,

What is the best way to add row components in ListBox? Say I have an empty ListBox at the beginning, and my program logic can generate the number of new rows to be added. The getNumRows() of ListBoxModel will be initialized to 0. I wanna update the number of rows, and then use updateContent() to create new row components. However, I couldn’t figure out how to update row number. Any help will be appreicated sincerely.

Liang

I haven’t used this ListBox feature so can’t ensure it works or if I’m talking nonsense, but why not generate a new data model (copying into it what you already had) with the new stuff you want. Then set it using setModel(). Take a look at the documentation

You just have to make it so the ListBoxModel returns one more when calling getNumRows() and notify the ListBox with updateContent().

You have total control what getNumRows() returns, since you implemented it (it was pure abstract in the ListBoxModel class).