-
Hello, i'm trying to insert items into a list box, but I can't seem to get it to do an insert. The additem always adds an item to the end. I tried setting the listindex and
then doing my additem, but it still adds to the bottom of the list. Here's a sample of my problem
listbox1
--------
Vehicle Type
1979 Buick cutlass
1990 Corevette Convertable
1972 Chrysler Cordoba
Property Type
Commercial
I have a prefilled listbox with vehicles and property types. I want to highlight a vehicle and click add. The vehicle should then show up on listbox2, which it does.
but if I add a vehicle, then a property type, and then
a vehicle, the list looks like:
listbox2 after user highlights and adds items from listbox1.
------------------------
Vehicle Type
1979 Buick cutlass
Land Type
Commercial
1990 Corevette Convertable - *** item, should be
under vehicle types.
how do you add items in a middle of a list.
thanks................
-
Two ways
1) Set sorted property to TRUE
2) Add the item at the desired position..Check Additem method documentation
-
Code:
Private Sub Command2_Click()
i = List1.ListIndex
List1.AddItem "hhh", i
End Sub
-
it sounds like you would be better off using the treeview control, that is if you don't mind adding to the size of the program.