# Remove item from 2004 ListBox

**URL:** <https://forum.kirupa.com/t/remove-item-from-2004-listbox/63032>\
**Category:** Uncategorized\
**Created:** [September 2, 2004, 1:41pm UTC](https://forum.kirupa.com/t/remove-item-from-2004-listbox/63032 "2004-09-02T13:41:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonesin](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@jonesin](https://forum.kirupa.com/u/jonesin)\
**Post date:** [September 2, 2004, 1:41pm UTC](https://forum.kirupa.com/t/remove-item-from-2004-listbox/63032/1 "2004-09-02T13:41:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 1:51pm UTC](https://forum.kirupa.com/t/remove-item-from-2004-listbox/63032/2 "2004-09-02T13:51:40Z")

</div>

```auto
mylistbox.removeItemAt(index);

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 2:45pm UTC](https://forum.kirupa.com/t/remove-item-from-2004-listbox/63032/3 "2004-09-02T14:45:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 2:47pm UTC](https://forum.kirupa.com/t/remove-item-from-2004-listbox/63032/4 "2004-09-02T14:47:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 2:57pm UTC](https://forum.kirupa.com/t/remove-item-from-2004-listbox/63032/5 "2004-09-02T14:57:31Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 3:25pm UTC](https://forum.kirupa.com/t/remove-item-from-2004-listbox/63032/6 "2004-09-02T15:25:09Z")

</div>

This should work:

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

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 3:31pm UTC](https://forum.kirupa.com/t/remove-item-from-2004-listbox/63032/7 "2004-09-02T15:31:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 3:35pm UTC](https://forum.kirupa.com/t/remove-item-from-2004-listbox/63032/8 "2004-09-02T15:35:51Z")

</div>

Glad i could help 🙂
