Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: CrAz3D on January 29, 2005, 02:02 PM

Title: Listview adding item after sorting
Post by: CrAz3D on January 29, 2005, 02:02 PM
        lvINFO.ListItems.Add , , cboType.Text
        lvINFO.ListItems(lvINFO.ListItems.Count).ListSubItems.Add , , txtTime.Text
        lvINFO.ListItems(lvINFO.ListItems.Count).ListSubItems.Add , , txtAmount.Text
        lvINFO.ListItems(lvINFO.ListItems.Count).ListSubItems.Add , , Date


I have my regular listview code that would typically add the itme @ the bottom of the listview...HOWEVER, since my items have been sorted the item is added in the listview according to where cboType.text should end up.  I'm not sure how to add the rest of the information (txtTime, txtAmount, & Date) to the correct index.  It wouldn't work by using the find function or w/e because cboType.text is listed multiple times in the listview already. 

Any ideas on how I would find the correct index to add the txtTime, txtAmount & Date to my listview?
Title: Re: Listview adding item after sorting
Post by: Adron on January 29, 2005, 05:04 PM
Doesn't Add return something for you to use if you need to reference the newly added item?
Title: Re: Listview adding item after sorting
Post by: CrAz3D on January 29, 2005, 05:25 PM
Well, the way I remedied this is busing some pscode code I found
Set lItem = lvINFO.ListItems.Add(, , cboType.Text)
        lItem.ListSubItems.Add , , txtTime.Text
        lItem.ListSubItems.Add , , FN.Amount(cboType.Text, txtTime.Text)
        lItem.ListSubItems.Add , , Date
        lItem.Selected = True

lItem is an iteger