Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listView - add item ?

Status
Not open for further replies.

ooops

MIS
Dec 21, 2000
91
US
I have a listView with 1 column. Please help me the way to add item in listView. The reason I'm trying to use listView instead of listbox b/c in VBA listbox does not have sort property. Thanks so much for your help.
 
ooops,

Below is some some old vb example/drill that adds some items and subitems to listview. Hope, it will help.

Dim itmNew As ListItem

With frmAutoInventory
Set itmNew = .lvwAuto.ListItems.Add(1, , "000001")
.lvwAuto.ListItems(1).Selected = False
.lvwAuto.ListItems(1).ListSubItems.Add , , "Ford"
.lvwAuto.ListItems(1).ListSubItems.Add , , "Taurus"
.lvwAuto.ListItems(1).ListSubItems.Add , , "2002"
.lvwAuto.ListItems(1).ListSubItems.Add , , "White"
.lvwAuto.ListItems(1).ListSubItems.Add , , "$23,000"

Set itmNew = .lvwAuto.ListItems.Add(2, , "000002")
.lvwAuto.ListItems(1).Selected = False
.lvwAuto.ListItems(2).ListSubItems.Add , , "Volkswagen"
.lvwAuto.ListItems(2).ListSubItems.Add , , "Passat"
.lvwAuto.ListItems(2).ListSubItems.Add , , "2002"
.lvwAuto.ListItems(2).ListSubItems.Add , , "Silverstone"
.lvwAuto.ListItems(2).ListSubItems.Add , , "$30,000"

Set itmNew = .lvwAuto.ListItems.Add(3, , "000003")
.lvwAuto.ListItems(1).Selected = False
.lvwAuto.ListItems(3).ListSubItems.Add , , "Lincoln"
.lvwAuto.ListItems(3).ListSubItems.Add , , "Continental"
.lvwAuto.ListItems(3).ListSubItems.Add , , "2001"
.lvwAuto.ListItems(3).ListSubItems.Add , , "Black"
.lvwAuto.ListItems(3).ListSubItems.Add , , "$34,000"


End With

vladk
 
I tried the code and I got the column header show up but not the subitems. They are all blank :-(
 
Have you got the ListView View property set to 3-lvwReport ?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top