Remove item from 2004 ListBox

Is there a simple method of removing a selected Item in a listbox (v.2) which was populated dynamically?

I have a feeling I have create a new function to loop thru the array again to remove the item that was selected.

mylistbox.removeItemAt(index);

thanks for the response claudio, but this listbox is being populated dynamically and there is more than one item in the list, so that code only works for the first item in the list that created at author time… so that doesnt work in my case

That’s not true, the removeItemAt method will work for dynamically populated data.
What exactly are you trying to do?

I have a list of 10 - 500 items, I want to be able to remove a selected item from the list, as I said in the initial post… so if the user selects item 34 and hits the delete key, that item is removed . . . .

and yes I know removeItemAt works for dynamically populated lists, however your code was not the answer… I tried it and failed. I then extended to something like

function removeTrack() {
listbox.removeItemAt(listbox.getSelectedItem());
}

This function removes the first item of the list… pooo

and that was wrong, I know how to do it but looping thru the original array that created the list, but thats just another 2 functions id rather not create if i dont need to…

This should work:

delete_btn.onPress = function() {
	listbox.removeItemAt(listbox.selectedIndex);
};

thank you claudio… works like a charm… I have no clue why I didnt see that before…( I think a mental brain-fart)

I appreciate the help.

Glad i could help :slight_smile: