ListView.AddItem???

Steff_DK

Registered User.
Local time
Today, 19:54
Joined
Feb 12, 2005
Messages
110
I am using a ListView control (6.0 i think) to sort some strings.
It has properties Visible=False and Sorted=Yes.

Then I run a loop that adds items one by one, and then gets the items out again (this time they will come out in sorted order - the whole point of the operation)

However, when i do:
Code:
Listitem = "oneoftheitems"
ListView.AddItem Listitem
I get error that the object doesn't support this method???

I took the code from my VB Project where it worked just fine on a Listbox.

How are items added with VBA in a ListView control?
 
The ListBox, in Access, gets it's data (typically) from a query specified in its RowSource property.
 
So a sql query as sourceobject should work?

Thanks! :)
 
By the way: How do I extract the values again?
ListView.ListItem(x) ???
 
Code:
Me.MyListBox.Column(0, 1)

0 = column number
1 = row number
 
ListBox population with an array

In addition to McAbney’s reply there are some situations where u don’t want to populate ListBox from table. In those scenarios the ListBox Rowsource property can be assigned to an array. And the RowSourceType property is set to "Value List".

Here is an example

Me.MyListBox.RowSourceType = "Value List"
Me. MyListBox.RowSource = myArr(counter)

And in order to concatenate

Me. MyListBox.RowSource = Me. MyListBox.RowSource & ";" & myArr(counter)

Regards Salman
 
Last edited:
Still doesn't work...

It is a ListVIEW not listbox...

Can someone make the attached work??

Thinking outside the (list)box :rolleyes:
 

Attachments

Private Sub Command1_Click()
Dim lvxObj As ListView
Dim lstItem As ListItem
Set lvxObj = ListView1.Object
Set lstItem = lvxObj.ListItems.Add(, , "Value To Add")
End Sub

However if you are just trying to sort a list of data then it is probably better to just put it into a table and use SQL to pull it back out in the order you need it.

HTH

Peter
 

Users who are viewing this thread

Back
Top Bottom