Listbox RemoveItem

Hi group, I have some problems usign the methods additem and removeitem in a list box, let me explain it:
1. First the user choose an option, example. breakfast, in order to this a list box is filled using a method with some options:

combobox.lostfocus[]
THISFORM.LISTBOX.AddItem["Eggs"]
THISFORM.LISTBOX.AddItem["Milk"]
THISFORM.LISTBOX.AddItem["Orange Juice"] etc...

But if the user decides to change his option, in this case, to change breakfast for lunch, I NEED TO ELIMINATE the items in the list box [eggs, milk, orange juice, etc] and to fill the listbox with the new options: "beef steak", "rice", chicken", so, the options: breakfast, lunch and dinner are contains in a combobox, when it gets the gotfocus[] method I do the remove item, like this:

combobox.gotfocus[]
THISFORM.LISTBOX.RemoveItem[1]
THISFORM.LISTBOX.RemoveItem[2]
THISFORM.LISTBOX.RemoveItem[3] ....

When I have more than 2 items in the listbox this code generate an error: "the object is out of range", I try to use the propertie lisIndex but without any result, what are you think?, please give me a hand.

Thanks a lot.
ishmael

Video liên quan

Chủ Đề